Konvertieren von Zeichenfolgen
I am working on a memory constraint 8/16 bit chip (8051) with only 32KB of ROM...
I am looking for a very small memory footprint version of the SHA256 calculator.
The version that I am using now is based on the classical version as found on wikipedia (https://en.wikipedia.org/wiki/SHA-2), but it compiles in around 1KB of flash (to get started, it uses 256 bytes for the 'table')...
Is there any (maybe slower) version of the algo which will be much more memory constrained?
Thanks,
Cyrille
How to hash some string with sha256 in Java ? Does anybody know any free library for this ?
I'm building an automated process to produce extensions. Is there a code example of calculating the extension-ID directly and entirely bypassing interaction with the browser?
(I'm answering my own question, below.)
I once unpacked the Clash Royale APK to see its contents. Noteworthy was a file called "Fingerprint.JSON", which contains paths to sound files and an associated hash value. My question is, why the hash value can be found in this file. I can imagine that before starting the app a hash value of an audio file is created and compared with the hash value in the file "Fingerprint.JSON". But that would not make sense, because I could also exchange the hash value itself to implement my own sounds.
Maybe someone can explain why these hash values can be stored publicly without causing security risks?
I am looking to decrypt a string using AES, I tried multiple solution from SO but none of them helped and I was unable to get the solution. The android developer used Cipher to do it below is the code for that:-
private static final byte[] initVector = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; private static Cipher getAES_Cipher(int opmode) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { IvParameterSpec iv = new IvParameterSpec(initVector); SecretKeySpec skeySpec = new SecretKeySpec(Arrays.copyOfRange(getSHA(key), 0, 32), "AES"); Cipher cipher = Cipher.getInstance("AES/CFB/PKCS5PADDING"); cipher.init(opmode, skeySpec, iv); return cipher;}
Similarly I tried using CryptoSwift to do it and below is the code I used to do it:-
extension String {func aesEncrypt(key: String, iv: String) throws -> String { let data: Array<UInt8> = (self.data(using: .utf8)?.bytes)! var key: Array<UInt8> = (key.data(using: .utf8)?.bytes)! let iv: Array<UInt8> = (iv.data(using: .utf8)?.bytes)! do { let encrypted = try AES(key: key, blockMode: CFB(iv: iv), padding: .pkcs5).encrypt(data) let encryptedData = Data(encrypted) let decrypted = try AES(key: key, blockMode: CFB(iv: iv), padding: .pkcs5).decrypt(encrypted) let decryptedData = Data(decrypted) let str = String.init(data: decryptedData, encoding: .utf8) print(str ?? String()) return encryptedData.base64EncodedString() } catch { print(error) return "error" }}func aesDecrypt(key: String, iv: String) throws -> String { let data: Array<UInt8> = (Data(base64Encoded: self)?.bytes)! let key: Array<UInt8> = (key.data(using: .utf8)?.bytes)! let iv: Array<UInt8> = (iv.data(using: .utf8)?.bytes)! do { let decrypted = try AES(key: key.sha256(), blockMode: CFB(iv: iv), padding: .pkcs5).decrypt(data) let decryptedData = Data(decrypted) guard let value = String.init(data: decryptedData, encoding: .utf8) else { return "error" } return value } catch { print(error) return "error" }}
}
and In ViewDidLoad() I called it like this:-
let message = "My Encrypted String From The Server" let test = try! message.aesDecrypt(key: "dfksjghlskjdfhglksjdfhglkjsdhfglkjhsfopweiurtypoweirutopiewrutgopiruegoijnsdeghsedrghesrerthigoererhehewthgewrhywertyweyweyewrtewrtyewihgoie", iv: "0000000000000000") print(test)
One more thing I want to highlight when I pass the same iv as android which is "{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }" I am getting the error from the CryptoSwift library as invalidInitializationVector but when I pass iv: "0000000000000000" I am getting an error -->
guard let value = String.init(data: decryptedData, encoding: .utf8) else { return "error" }
I believe it is something related to the iv that I am passing there.
Guys any help would be greatly appreciated!!
Thank You
Nach Hause - Sitemap - Privatleben - Links - Copyright © 2019 Cortex IT Ltd : In Kontakt Treten : admin @ cortexit.co.uk
Please note that by viewing our site you agree to our use of cookies (see Privatleben for details). You will only see this message once.