Skip to content

Commit 1ba479e

Browse files
authored
Merge pull request #1248 from firebase/rosalyntan.snippet
Add region tags
2 parents b5a7e01 + 4565699 commit 1ba479e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

authentication/LegacyAuthQuickstart/AuthenticationExample/MainViewController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,8 @@ - (void)startSignInWithAppleFlow {
10661066
[authorizationController performRequests];
10671067
}
10681068

1069+
// [START random_nonce]
1070+
// Adapted from https://auth0.com/docs/api-auth/tutorials/nonce#generate-a-cryptographically-random-nonce
10691071
- (NSString *)randomNonce:(NSInteger)length {
10701072
NSAssert(length > 0, @"Expected nonce to have positive length");
10711073
NSString *characterSet = @"0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._";
@@ -1097,7 +1099,9 @@ - (NSString *)randomNonce:(NSInteger)length {
10971099

10981100
return [result copy];
10991101
}
1102+
// [END random_nonce]
11001103

1104+
// [START sha_256]
11011105
- (NSString *)stringBySha256HashingString:(NSString *)input {
11021106
const char *string = [input UTF8String];
11031107
unsigned char result[CC_SHA256_DIGEST_LENGTH];
@@ -1109,6 +1113,7 @@ - (NSString *)stringBySha256HashingString:(NSString *)input {
11091113
}
11101114
return hashed;
11111115
}
1116+
// [END sha_256]
11121117

11131118
- (void)authorizationController:(ASAuthorizationController *)controller
11141119
didCompleteWithAuthorization:(ASAuthorization *)authorization API_AVAILABLE(ios(13.0)) {

authentication/LegacyAuthQuickstart/AuthenticationExampleSwift/MainViewController.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,7 @@ class MainViewController: UITableViewController {
10401040
authorizationController.performRequests()
10411041
}
10421042

1043+
// [START random_nonce]
10431044
// Adapted from https://auth0.com/docs/api-auth/tutorials/nonce#generate-a-cryptographically-random-nonce
10441045
private func randomNonceString(length: Int = 32) -> String {
10451046
precondition(length > 0)
@@ -1075,6 +1076,9 @@ class MainViewController: UITableViewController {
10751076
return result
10761077
}
10771078

1079+
// [END random_nonce]
1080+
1081+
// [START sha_256]
10781082
@available(iOS 13, *)
10791083
private func sha256(_ input: String) -> String {
10801084
let inputData = Data(input.utf8)
@@ -1085,6 +1089,8 @@ class MainViewController: UITableViewController {
10851089

10861090
return hashString
10871091
}
1092+
1093+
// [END sha_256]
10881094
}
10891095

10901096
@available(iOS 13.0, *)

0 commit comments

Comments
 (0)