CardEncryptor
public enum CardEncryptor : AnyEncryptor
An object that provides static methods for encrypting card information and retrieving public keys from the server.
-
Encrypts a card.
Throws
CardEncryptor.Error.encryptionFailed
if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.Throws
CardEncryptor.Error.invalidCard
when trying to encrypt a card with card number, securityCode, expiryMonth, and expiryYear, all of them are nil.Declaration
Swift
public static func encrypt(card: Card, with publicKey: String) throws -> EncryptedCard
Parameters
card
Card containing the data to be encrypted.
publicKey
The public key to use for encryption (format “Exponent|Modulus”).
Return Value
An encrypted card containing the individually encrypted fields.
-
Encrypts card number.
Throws
CardEncryptor.Error.encryptionFailed
if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.Throws
CardEncryptor.Error.invalidNumber
when trying to encrypt an empty or invalid card numberDeclaration
Swift
public static func encrypt(number: String, with publicKey: String) throws -> String
Parameters
number
The card number
publicKey
The public key to use for encryption (format “Exponent|Modulus”).
Return Value
An encrypted token containing card number data.
-
Encrypts security code.
Throws
CardEncryptor.Error.encryptionFailed
if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.Throws
CardEncryptor.Error.invalidSecureCode
when trying to encrypt an empty or invalid securityCode.Declaration
Swift
public static func encrypt(securityCode: String, with publicKey: String) throws -> String
Parameters
securityCode
The card’s security code.
publicKey
The public key to use for encryption (format “Exponent|Modulus”).
Return Value
An encrypted token containing security code data.
-
Encrypts expiration month.
Throws
CardEncryptor.Error.encryptionFailed
if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.Throws
CardEncryptor.Error.invalidExpiryMonth
when trying to encrypt an empty or invalid expiryMonth.Declaration
Swift
public static func encrypt(expirationMonth: String, with publicKey: String) throws -> String
Parameters
expiryMonth
The expiration month.
publicKey
The public key to use for encryption (format “Exponent|Modulus”).
Return Value
An encrypted token expiration month data.
-
Encrypts expiration year.
Throws
CardEncryptor.Error.encryptionFailed
if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.Throws
CardEncryptor.Error.invalidExpiryYear
when trying to encrypt an empty or invalid expiryYear.Declaration
Swift
public static func encrypt(expirationYear: String, with publicKey: String) throws -> String
Parameters
expiryMonth
The expiration year.
publicKey
The public key to use for encryption (format “Exponent|Modulus”).
Return Value
An encrypted token containing expiration year data.
-
Encrypt BIN.
Throws
CardEncryptor.Error.encryptionFailed
if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.Throws
CardEncryptor.Error.invalidBin
when trying to encrypt an empty or invalid BIN.Declaration
Swift
public static func encrypt(bin: String, with publicKey: String) throws -> String
Parameters
publicKey
The public key to use for encryption (format “Exponent|Modulus”).
bin
BIN( Bank Identification number) is the first 6 to 12 digits of PAN.
Return Value
An encrypted token containing BIN data.
-
Encrypts password.
Throws
CardEncryptor.Error.encryptionFailed
if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.Throws
CardEncryptor.Error.emptyValue
when trying to encrypt an empty value.Declaration
Swift
public static func encrypt(password: String, with publicKey: String) throws -> String
Parameters
password
The non-empty value.
publicKey
The public key to use for encryption (format “Exponent|Modulus”).
Return Value
An encrypted token containing expiration year data.
-
Encrypts a card as a token.
Throws
CardEncryptor.Error.encryptionFailed
if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.Throws
CardEncryptor.Error.invalidEncryptionArguments
when trying to encrypt a card with card number, securityCode, expiryMonth, and expiryYear, all of them are nil.Declaration
Swift
public static func encryptToken(from card: Card, with publicKey: String) throws -> String
Parameters
card
Card containing the data to be encrypted.
publicKey
The public key to use for encryption (format “Exponent|Modulus”).
Return Value
A string token containing encrypted card data.