SwifterTestsHMAC.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // SwifterTestsHMAC.swift
  3. // Swifter
  4. //
  5. // Copyright © 2016 Damian Kołakowski. All rights reserved.
  6. //
  7. import XCTest
  8. import Swifter
  9. class SwifterTestsHMAC: XCTestCase {
  10. func testSHA1() {
  11. XCTAssertEqual(HMAC.sha1([UInt8]("".utf8), [UInt8]("".utf8)), "fbdb1d1b18aa6c08324b7d64b71fb76370690e1d")
  12. XCTAssertEqual(HMAC.sha1([UInt8]("key".utf8), [UInt8]("The quick brown fox jumps over the lazy dog".utf8)),
  13. "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9")
  14. }
  15. func testSHA256() {
  16. XCTAssertEqual(HMAC.sha256([UInt8]("".utf8), [UInt8]("".utf8)), "b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad")
  17. XCTAssertEqual(HMAC.sha256([UInt8]("key".utf8), [UInt8]("The quick brown fox jumps over the lazy dog".utf8)), "f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8")
  18. }
  19. func testMD5() {
  20. XCTAssertEqual(HMAC.md5([UInt8]("".utf8), [UInt8]("".utf8)), "74e6f7298a9c2d168935f58c001bad88")
  21. XCTAssertEqual(HMAC.md5([UInt8]("key".utf8), [UInt8]("The quick brown fox jumps over the lazy dog".utf8)),
  22. "80070713463e7749b90c2dc24911e275")
  23. }
  24. }