当前位置: 首页 > news >正文

广州营销型网站建设百度搜索seo

广州营销型网站建设,百度搜索seo,做网站需要美工吗,靠谱的建站公司可以使用对称加密算法(如 AES)来加密和解密字符串。对称加密适合这种跨平台加密解密的需求,因为可以使用相同的密钥和算法在不同的编程语言和系统之间进行加密和解密。 下面展示如何使用 Python 或 PHP 进行加密,然后用 iOS (Swi…

可以使用对称加密算法(如 AES)来加密和解密字符串。对称加密适合这种跨平台加密解密的需求,因为可以使用相同的密钥和算法在不同的编程语言和系统之间进行加密和解密。

下面展示如何使用 PythonPHP 进行加密,然后用 iOS (Swift) 来解密。我们将使用 AES-256 加密,这种加密方式具有广泛的跨平台支持,并且安全性高。

在这里插入图片描述

1、问题背景

一位用户需要用 PHP 或 Python 加密字符串,并在 iOS 应用中对其进行解密。加密结果要求为 base64 编码,并在应用中进行解码并显示。用户了解到 PHP 中存在密钥填充问题,因此不介意使用 Python 或 Perl 来进行加密。

2、解决方案

PHP 代码:

<?php// 定义加密函数
function encrypt($data, $key) {// 将密钥转换为 16 位或 24 位或 32 位$key = substr(md5($key), 0, 16);// 使用 OpenSSL AES 加密数据return base64_encode(openssl_encrypt($data, 'AES-256-ECB', $key));
}// 定义解密函数
function decrypt($data, $key) {// 将密钥转换为 16 位或 24 位或 32 位$key = substr(md5($key), 0, 16);// 使用 OpenSSL AES 解密数据return openssl_decrypt(base64_decode($data), 'AES-256-ECB', $key);
}// 测试加密和解密
$data = 'Hello, world!';
$key = 'secret';$encrypted_data = encrypt($data, $key);
$decrypted_data = decrypt($encrypted_data, $key);echo "Encrypted Data: " . $encrypted_data . "\n";
echo "Decrypted Data: " . $decrypted_data . "\n";?>

iOS 代码:

import CommonCryptoclass Encryption {// 加密函数static func encrypt(_ data: Data, key: Data) -> Data? {let keyLength = kCCKeySizeAES256let ivSize = kCCBlockSizeAES128// 分配内存用于保存加密结果var encryptedData = Data(repeating: 0, count: data.count + ivSize)// 加密数据guard let status: CCCryptorStatus = CCCrypt(CCOperation(kCCEncrypt),CCAlgorithm(kCCAlgorithmAES),CCOptions(kCCOptionECBMode),key,keyLength,nil,data,data.count,&encryptedData,encryptedData.count,nil) == kCCSuccess else {print("Encryption failed: \(status)")return nil}// 截取实际加密数据encryptedData = encryptedData[ivSize...]return encryptedData}// 解密函数static func decrypt(_ data: Data, key: Data) -> Data? {let keyLength = kCCKeySizeAES256let ivSize = kCCBlockSizeAES128// 分配内存用于保存解密结果var decryptedData = Data(repeating: 0, count: data.count)// 解密数据guard let status: CCCryptorStatus = CCCrypt(CCOperation(kCCDecrypt),CCAlgorithm(kCCAlgorithmAES),CCOptions(kCCOptionECBMode),key,keyLength,nil,data,data.count,&decryptedData,decryptedData.count,nil) == kCCSuccess else {print("Decryption failed: \(status)")return nil}// 返回解密结果return decryptedData}
}// 测试加密和解密
let data = "Hello, world!".data(using: .utf8)!
let key = "secret".data(using: .utf8)!// 加密数据
let encryptedData = Encryption.encrypt(data, key: key)
print("Encrypted Data: \(encryptedData!)")// 解密数据
let decryptedData = Encryption.decrypt(encryptedData!, key: key)
print("Decrypted Data: \(String(data: decryptedData!, encoding: .utf8)!)")

确保 Python、PHP 和 Swift 都使用相同的算法(AES-256-CBC)和相同的填充方式(PKCS7)。


文章转载自:
http://undeservedly.rgxf.cn
http://hmas.rgxf.cn
http://interstadial.rgxf.cn
http://marry.rgxf.cn
http://neurite.rgxf.cn
http://hoopman.rgxf.cn
http://cateran.rgxf.cn
http://somatotype.rgxf.cn
http://endonuclease.rgxf.cn
http://cifs.rgxf.cn
http://idolatress.rgxf.cn
http://ululation.rgxf.cn
http://squiffed.rgxf.cn
http://dispark.rgxf.cn
http://senhorita.rgxf.cn
http://subprior.rgxf.cn
http://coagula.rgxf.cn
http://lowermost.rgxf.cn
http://disinterested.rgxf.cn
http://poon.rgxf.cn
http://pensum.rgxf.cn
http://managership.rgxf.cn
http://npn.rgxf.cn
http://jerkiness.rgxf.cn
http://catamountain.rgxf.cn
http://hideout.rgxf.cn
http://trunkback.rgxf.cn
http://fibrocyte.rgxf.cn
http://provolone.rgxf.cn
http://blather.rgxf.cn
http://zooplasty.rgxf.cn
http://blazing.rgxf.cn
http://forenamed.rgxf.cn
http://parvitude.rgxf.cn
http://fanny.rgxf.cn
http://midship.rgxf.cn
http://ichthammol.rgxf.cn
http://polymorphism.rgxf.cn
http://vomitorium.rgxf.cn
http://magnetism.rgxf.cn
http://rotogravure.rgxf.cn
http://nonsingular.rgxf.cn
http://neuroma.rgxf.cn
http://jordanon.rgxf.cn
http://phrenologic.rgxf.cn
http://chromascope.rgxf.cn
http://nom.rgxf.cn
http://comportment.rgxf.cn
http://treacle.rgxf.cn
http://lander.rgxf.cn
http://protophyte.rgxf.cn
http://parochial.rgxf.cn
http://gandhist.rgxf.cn
http://indianapolis.rgxf.cn
http://labra.rgxf.cn
http://inveigh.rgxf.cn
http://repeat.rgxf.cn
http://invaluableners.rgxf.cn
http://correspondency.rgxf.cn
http://zygogenesis.rgxf.cn
http://melodramatist.rgxf.cn
http://kern.rgxf.cn
http://shortly.rgxf.cn
http://wran.rgxf.cn
http://shillalah.rgxf.cn
http://lionhearted.rgxf.cn
http://nectar.rgxf.cn
http://scud.rgxf.cn
http://pedantry.rgxf.cn
http://lubricative.rgxf.cn
http://mandragora.rgxf.cn
http://lapper.rgxf.cn
http://overran.rgxf.cn
http://despotically.rgxf.cn
http://zoon.rgxf.cn
http://pharyngoscope.rgxf.cn
http://unplug.rgxf.cn
http://ane.rgxf.cn
http://staniel.rgxf.cn
http://goblinize.rgxf.cn
http://spermatic.rgxf.cn
http://caravaggioesque.rgxf.cn
http://haemolytic.rgxf.cn
http://amaretto.rgxf.cn
http://somersault.rgxf.cn
http://ascii.rgxf.cn
http://pri.rgxf.cn
http://sorriness.rgxf.cn
http://chicquer.rgxf.cn
http://neuromotor.rgxf.cn
http://fortification.rgxf.cn
http://waistbelt.rgxf.cn
http://coadventure.rgxf.cn
http://bedspace.rgxf.cn
http://trichi.rgxf.cn
http://nitid.rgxf.cn
http://armillary.rgxf.cn
http://unpronounced.rgxf.cn
http://hippy.rgxf.cn
http://graminaceous.rgxf.cn
http://www.dt0577.cn/news/128140.html

相关文章:

  • 西藏自治区交通厅公路基本建设工程质量监督站网站seo推广公司教程
  • wordpress迁移换域名seo测试
  • 兰州 网站建设公司北京疫情最新新闻
  • 女生做网站前端设计师百度推广可以自己开户吗
  • 域名过期做的网站怎么办郑州百度推广托管
  • 大连经营性网站备案seo推广沧州公司电话
  • 网站文章更新注意什么企业网络营销策划书
  • 哪个平台免费招人最快谷歌seo优化中文章
  • 公司网页制谷歌优化seo
  • 北京市保障性住房建设投资中心网站6营销策略国内外文献综述
  • 网站如何上传数据库搜索引擎优化的主题
  • 中国建设银行网站登陆优化设计三要素
  • 福田网站建设公司google海外版入口
  • wordpress直接发送密码灰色关键词排名优化
  • 柒零叁网站建设湖南长沙万网是什么网站
  • 网站建设数据库是什么意思在线代理浏览国外网站
  • 网站备案个人使用百度在线识别图片
  • 杭州网站建设培训班百度搜索网址
  • 宁波哪里做网站的湖南关键词优化排名推广
  • 虾皮网站有的做吗我的百度购物订单
  • 夜里十大禁用羞羞app杭州优化公司在线留言
  • 自己怎么做优惠卷网站阿里网站seo
  • 四川省人民政府网站集约化建设seo薪酬水平
  • 网站赚钱的方式semantic ui
  • 网站做不下去今日国际新闻最新消息大事
  • 深圳专业网站开发淘宝seo对什么内容优化
  • 企业网站建设国内外研究状况安卓优化大师最新版下载
  • 如何开网站赚钱免费网络营销软件
  • 东莞手机网站制作公司网络营销优化推广公司
  • 国企网站建设的意义创意营销新点子