hello , i need a coding?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hello
i am coding for hash512 algorithm. i have coded up to padding operations and i need to perform round functions can some one help me by providing the code to me. or can you please correct my code and resend to me. I need the output as a 512bits binary string converted to decimal data. i am attaching my code below.
data = input('enter the data:','s');
pawrd = input('enter the password:','s');
bin = double(data);
display(bin);
n = dec2base(bin,16);
display(n);
len_n = length(n);
display(len_n);
k = dec2bin(bin,8);
display(k);
pwd = dec2bin(pawrd,8)';
pwd = pwd(:)'-'0';
ln_pwd = length(pwd);
disp(ln_pwd);
pad_pwd = [pwd , ones(1,64-ln_pwd)];
A = dec2bin(data,8)';
A = A(:)'-'0';
le_a = length(A);
pad2 = dec2bin(le_a,8)';
pad2 = pad2(:)'-'0';
j = length(pad2);
dap2 = [zeros(1,128-j), pad2];
display(pad2);
display(A);
display(le_a);
x = 896-le_a;
display(x);
%%padding operation
if x == 0
display('seq need not to be padded');
else
padarray = [ones(1,1), zeros(1,x-1)];
paddedseq = [A, padarray];
finalpad = [paddedseq, dap2];
l_paddedseq = length(finalpad);
display(l_paddedseq);
display(paddedseq);
display(finalpad);
%%round function
x1 = '6A09E667F3BCC908';
x2 = 'BB67AE8584CAA73B';
x3 = '3C6EF372FE94F82B';
x4 = 'A54FF53A5F1D36F1';
x5 = '510E527FADE682D1';
x6 = '9B05688C2B3E6C1F';
x7 = '1F83D9ABFB41BD6B';
x8 = '5BE0CD19137E2179';
bx1 = base2dec(x1,16);
bx2 = base2dec(x2,16);
bx3 = base2dec(x3,16);
bx4 = base2dec(x4,16);
bx5 = base2dec(x5,16);
bx6 = base2dec(x6,16);
bx7 = base2dec(x7,16);
bx8 = base2dec(x8,16);
a = dec2bin(bx1,64);
display(a);
b = dec2bin(bx2,64);
display(b);
c = dec2bin(bx3,64);
display(c);
d = dec2bin(bx4,64);
display(d);
e = dec2bin(bx5,64);
display(e);
f = dec2bin(bx6,64);
display(f);
g = dec2bin(bx7,64);
display(g);
h = dec2bin(bx8,64);
display(h);
end w =reshape(finalpad,16,64); display(w);
wi = w(0+i, 1:64);
disp(wi);
ki = circshift(pad_pwd,1);
disp(ki);
and1 = e&f;
and2 = (~e)&g;
and3 = a&b;
and4 = a&c;
and5 = b&c;
Ch = bitxor(and1,and2);
display(and1);
display(and2);
display(Ch);
Maj1 = bitxor(and3,and4);
display(Maj1);
maj = bitxor(Maj1,and5);
display(maj);
r1 = circshift(e,[0 +14])-'0' ;
disp(r1);
r2 = circshift(e,[0 +18])-'0';
disp(r2);
r3 = circshift(e,[0 +41])-'0';
r4 = circshift(a,[0 +28])-'0';
r5 = circshift(a,[0 +34])-'0';
r6 = circshift(a,[0 +39])-'0';
r12 = bitxor(r1,r2);
r45 = bitxor(r4,r5);
sum1e = bitxor(r12,r3);
sum0a = bitxor(r45,r6);
T1 = h|Ch|wi|ki|sum1e;
disp(T1);
T2 = maj|sum0a;
disp(T2);
h = g;
disp(h);
g = f;
disp(g);
f = e;
disp(f);
e = d|T1;
disp(e);
d = c;
disp(d);
c = b;
disp(c);
b = a;
disp(b);
a = T1|T2;
disp(a);
a=a(a~='0');
disp(a);
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!