Cody

# Problem 45320. SHA256 Hashing

Solution 2215138

Submitted on 16 Apr 2020 by Binbin Qi
• Size: 45
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = 'aa'; y_correct = 'bceef655b5a034911f1c3718ce056531b45ef03b4c7b1f15629e867294011a7d'; assert(isequal(SHA256(x),y_correct))

2   Pass
x = 'aabbccddeeff'; y_correct = '17226b1f68aebacdef0746450f642874638b295707ef73fb2c6bb7f88e89929f'; assert(isequal(SHA256(x),y_correct))

3   Pass
x = 'aa0123456789bb0123456789cc0123456789dd0123456789dd0123456789ee0123456789ff0123456789'; y_correct = '28b51d5465661e7565dbaad0f57b972694ff96722ad6b1272cb62f867cd3d850'; assert(isequal(SHA256(x),y_correct))

4   Pass
x = '010203040506070809a1a2a3a4a5a6a7a8a9aaabacadaeaf'; y_correct = '05f6ae62f9e66bf381b8633f310203564ab5755a8ffeb5295df63d712b5b99b3'; assert(isequal(SHA256(x),y_correct))

5   Pass
x = '010203040506070809b0b1b2b3b4b5b6b7b8b9babbbcbdbebf'; y_correct = '58c146ab1f285afdad8a88d1431138c7c585a8681cd05f3e7463e8c5cab1d85b'; assert(isequal(SHA256(x),y_correct))

6   Pass
x = '3df36325c49b52091e2f0dce4ef073909d93e7ec4a173410cc1499c73dbcc30d05fccbd049451fc23b2aff7692ac8a19ca25'; y_correct = '65dc21caa32f64cc5761e7a33a4ce8444e5e92c581b109f40ab1c19137d6017a'; assert(isequal(SHA256(x),y_correct))

7   Pass
x = 'b3569682a918fcc931450689e344c0c3ffb7ba93c4e618d38147aa0ecfd86e00585054b3ed07e34e9e07b6b7b288cbbba02f72a627a1365258db4295a5c97aae5ce479f4c640c0fdf116a20ac626898f45ba4b49446de8efda170b13443dce1657e28d29'; y_correct = '515a258c12639a853a4b26787b57bb7a28e7c713d54c32e1ee69f475ee264315'; assert(isequal(SHA256(x),y_correct))

8   Pass
x = '3044ba9ded85376d8e56b86fb88e70d2afc5b71611d2cb22650544245ff343cdba78905e21ed126dc3e202ac51d48688176ed10d210c217a3ae40e3b26779e846c81b5264903742058db07007c0a2136d9c82ee83d63bd8860e0986b8ac2055b145e1cdcaba106fe095376730597b84501c1493e65215c00c25c662ec4cc521b1f7ef60f9604da3bef16473a062a40dfe008f23fdc5f'; y_correct = '2290847297dd385e81d854e5ace68c58b26dfd0113a7308b580329ca40533b67'; assert(isequal(SHA256(x),y_correct))

9   Pass
x = '3c724b57efe352bf7cf9e1c1540578341a631ec8131c966dcbe08225dea603580b7ff83b7ee929a2fac613ac1823bd6a6d5419a912e8301e8aa2ff0278761fea5099579ac78002f0a10fc06995f5908d0638b80e9ac8cbe177ecd8e652ea52166c2798878b5047a2701a2d3c9af0bd9b305856195f062bd21c8efd211e4cb31252eb219db17229f07bbbcdf020b37a014ba86f34bd724fb2cb464c1591021806873950671c89fde44f1f7ee8c889e6847a4fa2540b34915adfdabdd84ced6cbea51e5d1a09e025d0'; y_correct = 'a90514d0965382c793a5cfb5cd69fcdb36dcc68709c0ba8eeb1ac0a1af1cf428'; assert(isequal(SHA256(x),y_correct))

10   Pass
x = '1b7f378081dd1d40f56acc462e465935b0378ec3049a00db4e67bd7c74fd8395c1e0d55090e0bb41fde3ea787aa88377bb1397129dea43b8e57d940347564c6359fddbfd8520ae9a8cda95492ca640505f40d1d754afb1134b6372b53f57550039b79b42b7ae6f89fe5abefb544182b556cc58567bc6c46ec5dc96a4d4b04504bc108206ee027e921032e9ed735c8eab0cb05c5e25a62e9cd56e8e51d060e5a9039dfefa5b1ae7bf479531a1e5d94574260ff939af92f1491dd268a41cf9fa449d78e66c4e3fed5421ba1d23a3971492d170edd114789009f02799d9f1bc42f40dffde18f4d3fcf5ad843c8b70ff481dfc9dc25659c64d5435db'; y_correct = '6385659325be088ca568830f97a3495a693ced0541174d15bcf163c12f6ade46'; assert(isequal(SHA256(x),y_correct))

### Community Treasure Hunt

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

Start Hunting!