| 1 | // Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved. |
| 2 | // Use of this source code is governed by an MIT license |
| 3 | // that can be found in the LICENSE file. |
| 4 | import crypto.aes |
| 5 | |
| 6 | fn test_aes() { |
| 7 | key := '6368616e676520746869732070617373'.bytes() |
| 8 | mut ciphertext := '73c86d43a9d700a253a96c85b0f6b03ac9792e0e757f869cca306bd3cba1c62b'.bytes() |
| 9 | block := aes.new_cipher(key) |
| 10 | |
| 11 | block.encrypt(mut ciphertext, ciphertext.clone()) |
| 12 | assert ciphertext.hex() == '05d1737fe0a7c12088ff4c94d62ccbd9353361393663383562306636623033616339373932653065373537663836396363613330366264336362613163363262' |
| 13 | |
| 14 | block.decrypt(mut ciphertext, ciphertext.clone()) |
| 15 | |
| 16 | assert ciphertext.bytestr() == '73c86d43a9d700a253a96c85b0f6b03ac9792e0e757f869cca306bd3cba1c62b' |
| 17 | println('test_aes ok') |
| 18 | } |
| 19 | |