Browse Source

More crypto functions for Array<UInt8>

Marcin Krzyżanowski 10 years ago
parent
commit
8d636f4fcb
1 changed files with 12 additions and 0 deletions
  1. 12 0
      CryptoSwift/Array<UInt8>+Extension.swift

+ 12 - 0
CryptoSwift/Array<UInt8>+Extension.swift

@@ -39,5 +39,17 @@ extension Array where Element: _UInt8Type {
     public func crc32() -> [UInt8]? {
         return Hash.crc32(Element.arrayValue(self)).calculate()
     }
+    
+    public func encrypt(cipher: Cipher) throws -> [UInt8]? {
+        return try cipher.encrypt(Element.arrayValue(self))
+    }
+    
+    public func decrypt(cipher: Cipher) throws -> [UInt8]? {
+        return try cipher.decrypt(Element.arrayValue(self))
+    }
+
+    public func authenticate(authenticator: Authenticator) -> [UInt8]? {
+        return authenticator.authenticate(Element.arrayValue(self))
+    }
 
 }