Browse Source

README Cipher example updates

Marcin Krzyżanowski 11 years ago
parent
commit
479ac55570
1 changed files with 21 additions and 20 deletions
  1. 21 20
      README.md

+ 21 - 20
README.md

@@ -81,36 +81,27 @@ Hashing a String and printing result
         println(hash)
     }
     
-Working with Cipher
+Working with Ciphers
 
 	// convenience setup tuple
 	let setup = (key: keyData, iv: ivData)
 	
-	// encrypt
-	if let encrypted = Cipher.ChaCha20(setup).encrypt(dataToEncrypt) {
+	// ENCRYPT
+	let aesEncrypted = Cipher.AES(setup).encrypte(dataToEncrypt)
+	let chacha20Encrypted = Cipher.ChaCha20(setup).encrypt(dataToEncrypt)
 	
-	    // decrypt
-	    if let decrypted = Cipher.ChaCha20(setup).decrypt(encrypted) {
-	    
-	        // validate result
-	        if (encrypted.isEqual(decrypted)) {
-		        print("Decryption failed!")
-	        }
-	        
-	    }
-	}
+	// DECRYPT
+	let decryptedChaCha20 = Cipher.ChaCha20(setup).decrypt(encryptedData)
+	let decryptedAES = Cipher.AES(setup).decrypt(encryptedData)
 	
 
-with extensions
+using extensions
 	
 	// convenience setup tuple
 	let setup = (key: keyData, iv: ivData)
 
-	if let encrypted = dataToEncrypt.encrypt(Cipher.ChaCha20(setup)) {
-		if let decrypted = encrypted.decrypt(Cipher.ChaCha20(setup)) {
-			println(decrypted)
-		}
-	}
+	let encrypted = dataToEncrypt.encrypt(Cipher.ChaCha20(setup))
+	let decrypted = encrypted.decrypt(Cipher.ChaCha20(setup))
 	
 Message authenticators
 
@@ -121,4 +112,14 @@ Message authenticators
 Marcin Krzyżanowski [@krzyzanowskim](http://twitter.com/krzyzanowskim)
 
 ##Licence
-see LICENSE file
+
+Copyright (C) 2014 Marcin Krzyżanowski <marcin.krzyzanowski@gmail.com>
+This software is provided 'as-is', without any express or implied warranty. 
+
+In no event will the authors be held liable for any damages arising from the use of this software. 
+
+Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
+
+- The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
+- Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+- This notice may not be removed or altered from any source or binary distribution.