Can somebody help me with this please. I'm stuck due to my limited knowledge on Matlab.

조회 수: 3 (최근 30일)
Below is part of my code for an authentication system using Biometrics. I get the error message below when it comes to gi, the rest works. Please someone enlighten me Error using bitxor Inputs must have the same size.
PWi = input('Enter your password:' , 's');
IDi= input('Enter your identity :' ,'s');
Ki = input('Enter a random number of your choice : ');
Bi = imread('input.bmp');
Bi_double = double(Bi);
BiKi = bitxor(Bi_double,Ki);
fi = SHA(BiKi) % One way hash function on fi
%SHA 256 output --> fi = 6EEEE0B2284786DD416033159C3AE53E315CAE0FE7A95AB39160ED7CD7E5A685
fi_db = double(fi);
PWi_double = double(PWi)
IDiPWi = strcat(num2str(IDi),num2str(PWi));
IDiPWi_double = double(IDiPWi);
gi = bitxor(IDiPWi_double,fi_db) %this part is not working
% Error using bitxor
% Inputs must have the same size.
ji = bitxor(IDiPWi_double,Ki)
  댓글 수: 1
Gareth Thomas
Gareth Thomas 2014년 3월 22일
if you type:
size(IDiPWi_double) size(fi_db)
You will notice that the sizes do not match and the function needs them to be the same.
Hope this helps.

댓글을 달려면 로그인하십시오.

답변 (2개)

Gareth Thomas
Gareth Thomas 2014년 3월 22일
if you type:
size(IDiPWi_double)
size(fi_db)
You will notice that the sizes do not match and the function needs them to be the same.
Hope this helps.
  댓글 수: 1
Vidya
Vidya 2014년 3월 22일
Thank you for replying. Yes I did that before and I can't seem to find a solution for that, if there are any to begin with.
I need them both to be of the same size. Is there any way to achieve that?

댓글을 달려면 로그인하십시오.


Gareth Thomas
Gareth Thomas 2014년 3월 23일
Hi Vidya,
You can do a couple of things:
- force the inputs to be a particular size so that they add up to 256.
- given the strcat command, add characters until you get what you want. this probably plays a role in your algorithm
If you choose for the later, you could calculate how far off the sequence is and add a known letter with:
repmat('A',1,256-size(IDiPWi_double,2))
Or just add a random letter.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by