Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import android.content.Context;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.SurfaceView;
Expand All @@ -28,7 +29,6 @@
import com.yanzhenjie.permission.runtime.Permission;

import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;

import io.agora.api.example.MainApplication;
import io.agora.api.example.R;
Expand Down Expand Up @@ -255,7 +255,10 @@ private void enablePacketProcessor(boolean enable) {
}

private byte[] getKdfSaltFromServer() {
return "EncryptionKdfSaltInBase64Strings".getBytes(StandardCharsets.UTF_8);
// Salt string should be the output of the following command:
// openssl rand -base64 32
String saltBase64String = "NiIeJ08AbtcQVjvV+oOEvF/4Dz5dy1CIwa805C8J2w0=";
return Base64.decode(saltBase64String, Base64.DEFAULT);
}

private void joinChannel(String channelId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,14 @@ - (void)viewDidLoad {
[AgoraCustomEncryption registerPacketProcessing:self.agoraKit];

} else {
// Salt string should be the output of the following command:
// openssl rand -base64 32
NSString *saltBase64String = @"NiIeJ08AbtcQVjvV+oOEvF/4Dz5dy1CIwa805C8J2w0=";

AgoraEncryptionConfig *config = [[AgoraEncryptionConfig alloc] init];
config.encryptionMode = mode;
config.encryptionKey = secret;
config.encryptionKdfSalt = [@"EncryptionKdfSaltInBase64Strings" dataUsingEncoding:(kCFStringEncodingUTF8)];
config.encryptionKdfSalt = [[NSData alloc] initWithBase64EncodedString:(saltBase64String) options:(0)];
int ret = [self.agoraKit enableEncryption:YES encryptionConfig:config];
if (ret != 0) {
// for errors please take a look at:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ class StreamEncryptionMain: BaseViewController {
}

func getEncryptionSaltFromServer() -> Data {
return "EncryptionKdfSaltInBase64Strings".data(using: .utf8) ?? Data()
// Salt string should be the output of the following command:
// openssl rand -base64 32
let saltBase64String = "NiIeJ08AbtcQVjvV+oOEvF/4Dz5dy1CIwa805C8J2w0="
return Data(base64Encoded: saltBase64String.data(using: .utf8)!)!
}

override func willMove(toParent parent: UIViewController?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,10 @@ class StreamEncryption: BaseViewController {
}

func getEncryptionSaltFromServer() -> Data {

return "EncryptionKdfSaltInBase64Strings".data(using: .utf8)!
// Salt string should be the output of the following command:
// openssl rand -base64 32
let saltBase64String = "NiIeJ08AbtcQVjvV+oOEvF/4Dz5dy1CIwa805C8J2w0="
return Data(base64Encoded: saltBase64String.data(using: .utf8)!)!
}

func layoutVideos(_ count: Int) {
Expand Down