search
HomeBackend DevelopmentPHP Tutorial什么是签名?服务器和APP之间的API接口和数据怎么保证安全?

我听过一些签名和对称加密,但又不知道理解对么,你们一般服务器和APP之间怎么做的签名和加密,还有到底怎样才叫签名啊?先谢大神了。

回复内容:

我听过一些签名和对称加密,但又不知道理解对么,你们一般服务器和APP之间怎么做的签名和加密,还有到底怎样才叫签名啊?先谢大神了。

access token是一种方式,早期简单点的有appid,appkey方式,复杂一点的可以使用RSA加密

楼主的问题应该是怎么进行加密通讯防止API外部调用吧,给你一个我的方案
服务器端与客户端各自会存储一个TOKEN,这个TOKEN我们为了防止反编译是用C语言来写的一个文件并做了加壳和混淆处理。
在客户端访问服务器API任何一个接口的时候,客户端需要带上一个特殊字段,这个字段就是签名signature,签名的生成方式为:
访问的接口名+时间戳+加密TOKEN 进行整体MD5,并且客户端将本地的时间戳作为明文参数提交到服务器
服务器首先会验证这两个参数:验证时间戳,如果时间误差与服务器超过正负一分钟,服务器会拒绝访问(防止被抓包重复请求服务器,正负一分钟是防止时间误差,参数可调整),
然后服务器会根据请求的API地址和提交过来的时间戳再加上本地存储的token按照MD5重新生成一个签名,并比对签名,签名一致才会通过服务器的验证,进入到下一步的API逻辑

服务器和APP直接大部分通过接口调用,比如 用户列表。/user/list/
post 到/user/list/里面有加密的一个token 这个是验证你是不是一个合法的访问者。而且现在很多开发平台比如微信。

什么是签名?服务器和APP之间的API接口和数据怎么保证安全?
这个就是 一个签名合法验证的一个例子。他们通过一些加密的机制和token 进行二次加密。然后获得合法的验证。
你可以加群:231566327 进行深入聊下。

签名和对称加密呢? 一般,签名用的是非对称加密的算法,比如你们公司有两个系统(A,B),那这两个系统就是可以互相信任的,但你又不希望从A登录到B需要输入用户名密码(因为这样会有泄漏用户阿),然后你就可以配置一个非对称加密的签名方式。比如在A保存非对称加密算法的私钥,B保存对应的公钥。用A里的私钥随便加密一点东西传到B,B就可以通过公钥证明A的身份,的确是来自A了。
非对称加密就更不用说了///

https呗

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Performance Tuning for High Traffic WebsitesPHP Performance Tuning for High Traffic WebsitesMay 14, 2025 am 12:13 AM

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

Dependency Injection in PHP: Code Examples for BeginnersDependency Injection in PHP: Code Examples for BeginnersMay 14, 2025 am 12:08 AM

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

PHP Performance: is it possible to optimize the application?PHP Performance: is it possible to optimize the application?May 14, 2025 am 12:04 AM

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

PHP Performance Optimization: The Ultimate GuidePHP Performance Optimization: The Ultimate GuideMay 14, 2025 am 12:02 AM

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor