我要提前说一下,我对密码学(对基础知识)了解不多。我正在尝试实施凭据OpenHome服务,并且想对密码进行加密以将其发送到设备。
设备提供了用C编写的函数,该函数返回如下所示的公共密钥String:
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCzjFGuEKD0uWxzb47oRbiSP2uDwVJPeWU7m9VXi626V6lameTzdtwj2eYVZTIAsAW7yW4or2skn7oHqFG4GvhMzgMwoQjKFxeCPPFXRSotnt26AN1DhvFJp3V/d+MpmkzI07iWcD5eNe4EVNK9GSE4JOEHhJ/JYBVMiu04XE5aqwIDAQAB
Run Code Online (Sandbox Code Playgroud)
Android实现已经完成,给出的规范是
具有SHA-256和MGF1填充的RSA / ECB / OAEP
还有一个网站在加密时提供“说明”
http://wiki.openhome.org/wiki/Av:Developer:CredentialsService
到目前为止,我已经尝试过这些库:
SwiftyRSA,Heimdall,SwCrypt
我真的觉得我的主要失败之一是我不了解自己拥有的东西,我需要什么以及最终如何使用swift快速实现它。
理想情况下,我将具有如下功能
func encryptMessage(message:String, whithPublicKey key:String)->String
Run Code Online (Sandbox Code Playgroud)
非常感谢你。
我正在尝试为我工作的公司执行 POC,以了解在我们的项目中使用 DocC 可以获得的潜在价值。
在开发之前,我看了 WWDC 2021 上与 DocC 相关的 4 个视频,访问了Apple 开发者网站并阅读了一些页面和博客来收集一些信息和想法。
对于我的开发,我开始在我的开发计算机上使用 MAMP,然后将工作推送到服务器。
到目前为止,我认为我已经完成了在网站上托管文档存档的所有必要步骤。然而,我想知道我是否错过了一些东西,因为我的index.html 看起来是空白的。
我使用的代码是:
index.html(主要)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DocC POC</title>
</head>
<body>
<h2>Welcome</h2>
<button onclick="location.href = 'documentation/index.html';" id="myButton" class="float-left submit-button" >Read data framwework documentation</button>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
.htaccess
# Enable custom routing.
RewriteEngine On
# Route documentation and tutorial pages.
RewriteRule ^(documentation|tutorials)\/.*$ Data.doccarchive/index.html [L]
# Route files and data for the documentation archive.
#
# If …Run Code Online (Sandbox Code Playgroud) 我的应用程序需要有一个隐藏/专用(如果可能)文件夹,用于存储应用程序自行生成的音频文件。该音频文件用于构建数据库,如果需要,只有应用可以填充和删除该数据库。
用户唯一能做的活动就是将名为“已导出”的文件夹中的某些文件导出到共享文件夹或iCloud中。
问题是,如何在用户没有权限的情况下创建此隐藏/专用文件夹?
我试图了解我可以在协议中使用多少泛型。我的想法如下:
protocol Network {
func fetchCodable<T:Codable>(urlRequest:URLRequest, completion:@escaping (Result<T,Error>)->Void)
}
Run Code Online (Sandbox Code Playgroud)
然后我创建一个名为 AppNetwork 的类来实现网络协议。
extension AppNetwork:Network{
func fetchCodable<T>(urlRequest: URLRequest, completion: @escaping (Result<T, Error>) -> Void) where T : Decodable, T : Encodable {
URLSession.shared.dataTask(with: urlRequest) { (data, response, error) in
if let error = error {
completion(.failure(error))
return
}
guard let data = data else{
completion(.failure(AppNetworkError.dataCorrupted))
return
}
do {
let response = try JSONDecoder().decode(T.self, from: data)
completion(.success(response))
}
catch let decodeError{
completion(.failure(decodeError))
}
}.resume()
}
Run Code Online (Sandbox Code Playgroud)
此类是 NetworkHelper 的一部分,它实现了检索数据的功能,例如:
class NetworkHelper{
let …Run Code Online (Sandbox Code Playgroud) 我想做一件非常简单的事,但我无法弄清楚如何;
NSInteger * a=10;
a=a-1;
NSlog(@"a=%d",a);
Run Code Online (Sandbox Code Playgroud)
出于某种原因,它正在显示a=6.
怎么会这样?
我正在尝试将 Fastlane 实现到包含 30 多个应用程序的 Xcode 项目中。
此时此刻,我陷入了为“AppStore”构建应用程序的困境,因为它必须更改特定目标的版本和内部版本号。我的车道的代码是:
desc "Archives and creates the app for the AppStore"
lane :build_appstore do |options|
scheme = options[:scheme]
output_directory = options[:output_directory]
configuration = options[:configuration]
export_method = options[:export_method]
bundle_id = options[:bundle_id]
version = options[:version]
build = options[:build]
# Used for increment_version_number. Does it work?
ENV["APP_IDENTIFIER"] = options[:bundle_id]
increment_version_number(
version_number: version
)
increment_build_number(
build_number: build
)
gym(
scheme: scheme,
output_directory: output_directory,
configuration: configuration,
export_method: export_method
)
end
Run Code Online (Sandbox Code Playgroud)
这些通道可以工作,但是当我查看该项目时,我发现所有目标的版本和内部版本号都发生了变化,这有点不方便。
有任何想法吗??
我正在开发一个应用程序,该应用程序使用的 API 存在一些不一致,我已经通过这 2 个执行一些共享操作的 observable 取得了结果,但第一个“服务器”是一个绑定到 UITableView 的数组。
serversViewModel.servers
.asObservable()
.observeOn(MainScheduler.instance)
.bind(to: serversTableView.rx.items(cellIdentifier: ServersTableViewCell.identifier, cellType: ServersTableViewCell.self)) { [weak self] (row, element, cell) in
guard let strongSelf = self else { return }
cell.serverProxy.accept(element)
if let currentServer = strongSelf.serversViewModel.currentServer.value,
element == currentServer,
let index = strongSelf.serversViewModel.servers.value.firstIndex(where: { $0 == currentServer }){
strongSelf.serversTableView.selectRow(at: IndexPath(row: index, section: 0), animated: true, scrollPosition: .top)
}
}
.disposed(by: disposeBag)
serversViewModel.currentServer
.asObservable()
.observeOn(MainScheduler.instance)
.subscribe(onNext: { [weak self] (server) in
guard let strongSelf = self …Run Code Online (Sandbox Code Playgroud) 我有以下功能
public func encryptWithRSAKey(_ data: String, rsaKeyRef: SecKey, padding: SecPadding) -> [UInt8]? {
let blockSize = SecKeyGetBlockSize(rsaKeyRef)
var messageEncrypted = [UInt8](repeating: 0, count: blockSize)
var messageEncryptedSize = blockSize
var status: OSStatus!
status = SecKeyEncrypt(rsaKeyRef, SecPadding.OAEP, data, data.count, &messageEncrypted, &messageEncryptedSize)
if status != noErr {
print("\(logClassName): Encryption Error!")
}
return messageEncrypted
}
Run Code Online (Sandbox Code Playgroud)
输出为 encryptedMessage = [9,43,128...] 128 长度
我必须将结果发送到 C 函数中
void STDCALL CpProxyAvOpenhomeOrgCredentials1BeginSet(THandle aHandle, const char* aId, const char* aUserName, const char* aPassword, uint32_t aPasswordLen, OhNetCallbackAsync aCallback, void* aPtr)
{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 ruby 将任何类转换为哈希。我所做的初步实现:
class Object
def to_hash
instance_variables.map{ |v|
Hash[v.to_s.delete("@").to_sym, instance_variable_get(v)] }.inject(:merge)
end
end
Run Code Online (Sandbox Code Playgroud)
一切似乎都正常。但是当我尝试以下代码时:
class Person
attr_accessor :name, :pet
def initialize(name, pet)
@name = name
@pet = pet
end
end
class Pet
attr_accessor :name, :age
def initialize(name, age)
@name = name
@age = age
end
end
tom = Person.new("Tom", Pet.new("Tobby", 5))
puts tom.to_hash
Run Code Online (Sandbox Code Playgroud)
我有以下输出
{:name=>"Tom", :pet=>#<Pet:0x0055ff94072378 @name="Tobby", @age=5>}
Run Code Online (Sandbox Code Playgroud)
我无法散列 Pet 类型的属性 pet(或任何其他自定义类)
有任何想法吗?
编辑 这就是我希望返回的内容:
{:name=>"Tom", :pet=>{ :name=>"Tobby", :age=>5}}
Run Code Online (Sandbox Code Playgroud)