Explorar o código

More crypto functions for Array<UInt8>

Marcin Krzyżanowski %!s(int64=10) %!d(string=hai) anos
pai
achega
8d636f4fcb
Modificáronse 1 ficheiros con 12 adicións e 0 borrados
  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))
+    }
 
 }