uwsgi: option is ambiguous: http
利用qq邮箱作为个人邮件服务器发送邮件

用最简单方法解决api接口安全问题,几乎无法破解

妙音 posted @ 2019年1月01日 11:45 in python with tags web python , 3048 阅读
 

 场景描述

 
项目需要为第三方提供api服务接口。接口涉及到核心功能,如何保证接口安全。防止伪造身份、篡改数据?
 

思路

 
保障数据安全最好的方法,当然是加密了。无法解析内容,自然无法伪造,篡改。

可是使用https证书需要收费的。有其它方法么?

有的。

消息哈希认证(hmac)。
 
 

 算法描述

 
*  访问者
 
1. 当访问接口时, 将参数按key值排序,组成key1=value1&key2=value2&....&secret_key=...
2. 然后对上面结果做md5,生成签名sign
3. 将sign放到加入请求的参数
 
* 被访问者
 
密钥是被访问者提供了,它也有访问者的secret_key.
1.根据app_id查到secret_key
2.处理请求参数,按规则组成key1=value1&key2=value2....&secret_key=...
3.对上一步结果做md5,生成sign。比较两个sign,相等则身份验证通过
 

效果

 
1. 密钥只存在双方机器上,不可能被截取
2. 签名无法伪造,同样身份无法伪造、消息无法被篡改
 
使用了hmac认证,接口被破解基本是不可能的
 

python实现

 
import md5

app_id=123
secret_key="xxxxxxxx"

request_param = dict(
    key1="value1",
    key2="value2",
    key3="value3"
)

def sign():
    params = ["%s=%s" % (key, value) for key, value in sorted(request_param.items(), key=lambda item: item[0])]
    params.append("secret_key=%s" % secret_key)
    str_param = "&".join(params)
    print str_param
    md = md5.md5()
    md.update(str_param)
    return md.hexdigest()

if __name__ == '__main__':
    print(sign())
 
 
来源
 

 

Avatar_small
Zeeworld 说:
2019年9月02日 02:31

I am unable to read articles online very often, but I’m glad I did today. This is very well written and your points are well-expressed. Please, don’t ever stop writing.

Avatar_small
MHR Writer 说:
2019年9月30日 13:22

It's really hard to complete the chest.MHR Writer

Avatar_small
Buy website Traffic 说:
2019年10月10日 12:38

Without fail, your writing style is top professional; even your website also looks amazing thank you for posting.

Avatar_small
remembrance sunday q 说:
2019年10月11日 20:21

A great content material as well as great layout. Your website deserves all of the positive feedback it’s been getting. I will be back soon for further quality contents.

Avatar_small
talk to random peopl 说:
2019年10月23日 22:16

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free.

Avatar_small
http://vigile.quebec 说:
2019年10月25日 09:37

Excellent website! I adore how it is easy on my eyes it is. I am questioning how I might be notified whenever a new post has been made. Looking for more new updates. Have a great day!

Avatar_small
ménage à domicile pa 说:
2019年10月25日 18:03

You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant!

Avatar_small
f88tw 说:
2019年10月27日 11:05

敬启者:个人小网站希望大家多多支持 感谢您对我们热心的支持 f88tw┃华歌尔┃I appreciate your kind assistance. http://mypaper.pchome.com.tw/f88tw/P1 http://mypaper.pchome.com.tw/f88tw/post/1379131888 http://mypaper.pchome.com.tw/f88tw/post/1370781143|墓园|禁忌|捡骨师|新竹|台北|桃园|苗栗|头份|

Avatar_small
talk to random peopl 说:
2019年10月29日 09:22

 

I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post.  talk to random people online

 

 

Avatar_small
avast premier crack 说:
2019年10月29日 14:01

Here at this site really the fastidious material collection so that everybody can enjoy a lot.

Avatar_small
Jacket Master 说:
2019年10月30日 18:17

Amazing knowledge and I like to share this kind of information with my friends and hope they like it they why I do

Avatar_small
Prined boxes 说:
2019年11月01日 18:54

This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.

Avatar_small
http://cuisipat.com 说:
2019年11月02日 10:10

Superior post, keep up with this exceptional work. It's nice to know that this topic is being also covered on this web site so cheers for taking the time to discuss this! Thanks again and again!

Avatar_small
assignment help onli 说:
2019年11月04日 14:41

Thanks a lot to think about us and write such a beautiful article, always give your best and be successful in your future, I have a good process to make assignment by assignment help online through our expert.

Avatar_small
http://blackgromstud 说:
2019年11月05日 18:58

This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.

Avatar_small
seo 说:
2019年11月06日 22:48

 

You have performed a great job on this article. It’s very precise and highly qualitative. You have even managed to make it readable and easy to read. You have some real writing talent. Thank you so much. http://test.otowroclaw.com/news.php?id=74487&tytul=zbliza-sie-polcon-2012

Avatar_small
morning desert safar 说:
2019年11月09日 09:46

Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign.

Avatar_small
https://www.otodolny 说:
2019年11月12日 22:15

This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.

Avatar_small
Assignment Help 说:
2019年11月13日 14:28

Found your post interesting to read. Sometimes, It become troublesome to make time for writing assignments. We understand such situation. We provide you assignment help service for students and complete it for you before the deadline.

Avatar_small
All Assignment Help 说:
2019年11月13日 14:30

Found your post interesting to read. Sometimes, It become troublesome to make time for writing assignments. We understand such situation. We provide you assignment help service for students and complete it for you before the deadline.

Avatar_small
https://www.wykop.pl 说:
2019年11月21日 11:05

This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.

Avatar_small
tomtom go navigation 说:
2019年11月23日 11:06

This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.

Avatar_small
http://wizaz.pl/foru 说:
2019年11月24日 10:55

Very good points you wrote here..Great stuff...I think you've made some truly interesting points.Keep up the good work.

Avatar_small
click over here 说:
2019年11月24日 17:51

A great website with interesting and unique material what else would you need.

Avatar_small
seoagency 说:
2019年11月25日 20:44

ellent website! I adore how it is easy on my eyes it is. I am questioning how I might be notified whenever a new post has been made. Looking for more new updates. Have a great day! http://www.chezbeckyetliz.com/2006/06/blogs-de-cuisine-france-sites-utiles-en-grande-bretagne.html

Avatar_small
voyance immediate 说:
2019年11月26日 19:58

This is just the information I am finding everywhere. Thanks for your blog, I just subscribe your blog. This is a nice blog..

Avatar_small
eva sâm tố nữ 说:
2019年11月27日 11:12

This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.

Avatar_small
https://www.cancerco 说:
2019年11月27日 18:59

Thank you for very usefull information..

Avatar_small
Assignment Help 说:
2019年11月29日 16:54

We offer the best online assignment help and academic writing service in AUS, UK & USA. Hire native experts now & get FLAT 20% OFF on your first order.

Avatar_small
Dissertation Editing 说:
2019年11月29日 18:17

Need Dissertation Help UK? GotoDissertationHelp offers Online Dissertation Help Services by top Phd Experts. Get Instant dissertation help now !

https://www.gotodissertationhelp.co.uk/marketing-dissertation-help/
https://www.gotodissertationhelp.co.uk/dissertation-writing-help/

https://www.gotodissertationhelp.co.uk/ae/

Avatar_small
Assignment help 说:
2019年11月29日 19:16

We can help you whenever and where ever you want, We are giving services all over world and especially in Australia in following catagories: Assignment help

Avatar_small
catalytic oxidizer d 说:
2019年11月30日 10:14

I really like your take on the issue. I now have a clear idea on what this matter is all about..

Avatar_small
Before Orion 说:
2019年12月01日 10:40

I'm glad to see the great detail here!.

Avatar_small
http://www.fourwinds 说:
2019年12月01日 13:13

This is a good post. This post gives truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. Thank you so much. Keep up the good works.

Avatar_small
recuperative thermal 说:
2019年12月03日 11:01

I really like your take on the issue. I now have a clear idea on what this matter is all about..

Avatar_small
정보이용료 현금화 说:
2019年12月05日 21:28

I was reading some of your content on this website and I conceive this internet site is really informative ! Keep on putting up.정보이용료 현금화

Avatar_small
seoagency 说:
2019年12月07日 15:19

 

I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. Malwarebytes Full Keygen Download

Avatar_small
aileen 说:
2019年12月07日 20:14

I just couldn't leave your website before telling you that I truly enjoyed the top quality info you present to your visitors? Will be back again frequently to check up on new posts. Breaking News Today

Avatar_small
http://lizzyshealthy 说:
2019年12月08日 13:14

I was reading some of your content on this website and I conceive this internet site is really informative ! Keep on putting up

Avatar_small
seoagency 说:
2019年12月08日 15:20

I’ve been surfing online more than three hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my opinion, if all webmasters and bloggers made good content as you did, the web will be a lot more useful than ever before. Ummy Video Downloder Full Crack

Avatar_small
http://dir.whatuseek 说:
2019年12月08日 17:13

I love the way you write and share your niche! Very interesting and different! Keep it coming! [url=http://dir.whatuseek.com/Reference/Education/Special_Education/Inclusion]http://dir.whatuseek.com/Reference/Education/Special_Education/Inclusion[/url]

Avatar_small
aileen 说:
2019年12月09日 20:07

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with extra information? It is extremely helpful for me. thermal underwear for men

Avatar_small
seoagency 说:
2019年12月09日 21:55

The article looks magnificent, but it would be beneficial if you can share more about the suchlike subjects in the future. Keep posting. Filmora 9.2.10 Crack

Avatar_small
seoagency 说:
2019年12月11日 15:41

I read that Post and got it fine and informative. Lumion 10 Pro Crack full Download 2020

Avatar_small
Zonnepanelen install 说:
2019年12月11日 17:24

This is a great high resolution screen which you have shared for the users. Making a website is not an easy task but managing a good website is really a hard work. As far as this website is concerned, I am very happy. [url=https://zonnepanelen-installateur.be/]Zonnepanelen installateur[/url]

Avatar_small
seoagency 说:
2019年12月14日 22:39

 

Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share. Best Cleaning company in Abu Dhabi

Avatar_small
seoagency 说:
2019年12月15日 20:23

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. franchise business

Avatar_small
seoagency 说:
2019年12月16日 21:24

This blog is so nice to me. I will keep on coming here again and again. Visit my link as well.. adwords clicker bot

Avatar_small
seoagency 说:
2019年12月17日 19:18

When you use a genuine service, you will be able to provide instructions, share materials and choose the formatting style. Buy premium Authentic Documents

Avatar_small
https://oregontruffl 说:
2019年12月18日 00:10

Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing

Avatar_small
seoagency 说:
2019年12月18日 21:53

y awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. Youtube seo

Avatar_small
aileen 说:
2019年12月23日 16:20

Thanks for a wonderful share. Your article has proved your hard work and experience you have got in this field. Brilliant .i love it reading. gtv news website

Avatar_small
aileen 说:
2019年12月23日 18:59

Thanks for this great post, i find it very interesting and very well thought out and put together. I look forward to reading your work in the future. Rent a car in Dubai

Avatar_small
f88tw┃华歌尔 说:
2019年12月28日 08:31

敬启者:个人小网站希望大家多多支持 感谢您对我们热心的支持 f88tw┃华歌尔┃I appreciate your kind assistance. f88tw|墓园|捡骨流程|捡骨费用|捡骨时间|禁忌|捡骨颜色|捡骨师|新竹|时间|台北|桃园|苗栗|头份|火化|晋塔|安葬|法事|捡骨|看日子|墓穴|墓园|坟墓

Avatar_small
Zee sayings 说:
2020年1月01日 17:27

Positive site, where did u think of the data on this posting? I'm satisfied I found it, however, I will be returning soon to <a href=" http://www.publictvmedia.net/"> Digital marketing agency in Dubai</a>

Avatar_small
Micheal 说:
2020年1月09日 18:16

<a href="https://gistgallery.com/">favorite music</a>

Avatar_small
Making an essay 说:
2020年1月09日 18:17

Such an informative set of information. The format or the layout of the write-up is very impressive and it provides the readers with an idea of how to portray a serious matter in such an interesting manner. I will want to thank the admin and let know that going through the article was worthy. I work as an academic consultant for a website which provides academic solutions to students. Therefore, I will share the link of this website with students asking me questions regarding the process of making an essay.

Avatar_small
seoagency 说:
2020年1月27日 16:27

Someone Sometimes with visits your blog regularly and recommended it in my experience to read as well. The way of writing is excellent and also the content is top-notch. Thanks for that insight you provide the readers! Unique SEO BackLinks

Avatar_small
JOHN 说:
2020年2月02日 22:19

ool stuff you have got and you keep update all of us. SEO Services OffPage

Avatar_small
JOHN 说:
2020年2月07日 18:16

ks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts. carpet abu dhabi

Avatar_small
JOHN 说:
2020年2月08日 00:01

ood post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. http://abudhabicarpet.ae

Avatar_small
JOHN 说:
2020年2月09日 04:08

I really loved reading your blog. It was very well authored and easy to understand. Unlike other blogs I have read which are really not that good.Thanks alot! Top-notch services from website SEO Services

Avatar_small
Nursing Assignment W 说:
2020年2月10日 21:43

Students who seek <a href="https://researchpapers247.com/nursing-assignment-writing/"> Nursing Assignment Writing Services Online</a> from a writing company are guaranteed of getting good grades for their <a href="https://researchpapers247.com/nursing-assignment-writing/"> Nursing Assignment Writing Help</a> and <a href="https://researchpapers247.com/nursing-assignment-writing/"> Online Nursing Assignment Writing Services</a> that are free from grammatical errors.

Avatar_small
Nursing Research Pap 说:
2020年2月10日 21:44

Companies offering Nursing Research Paper Writing Services should help students perform well by delivering papers prior to deadline as early delivery of Custom Nursing Research Papers and Nursing Term Paper Writing Services is very important.
https://www.meldaresearch.com/nursing-research-papers/

Avatar_small
JOHN 说:
2020年2月10日 22:27

 

Thanks for the nice blog. It was very useful for me. I'm happy I found this blog. Thank you for sharing with us,I too always learn something new from your post. articles

Avatar_small
JOHN 说:
2020年2月14日 23:32

h for this information. I have to let you know I concur on several of the points you make here and others may require some further review, but I can see your viewpoint. Jet Charter

Avatar_small
seoagency 说:
2020年2月16日 21:47

Thanks for sharing us. best desert safari dubai

Avatar_small
seoagency 说:
2020年2月22日 23:09

I found your this post while searching for some related information on blog search...Its a good post..keep posting and update the information. t3 curling iron

Avatar_small
auto insurance in Yu 说:
2020年2月24日 04:03

I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.

Avatar_small
seoagency 说:
2020年2月24日 19:45

I would like to say that this blog really convinced me to do it! Thanks, very good post. Jobs in Pakistan 2020

Avatar_small
seoagency 说:
2020年2月29日 19:26

Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. Happy Birthday Mum

Avatar_small
seoagency 说:
2020年3月01日 18:26

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. Mobile phones news

Avatar_small
seoagency 说:
2020年3月02日 20:21

What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. khabibvsfergusonlivestream.com

Avatar_small
JOHN 说:
2020年3月04日 20:04

ol post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. buy reviews on google

Avatar_small
seoagency 说:
2020年3月07日 18:36

Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place.. https://watchkhabibvsdustin.com

Avatar_small
Backlinks Blog Comme 说:
2020年3月09日 02:28

Great blog post you have shared here. Thank you

Avatar_small
Robinjack 说:
2020年3月09日 22:59

Fantastic read, I just passed this onto a friend who was doing a little study on that. And he actually bought me lunch because I discovered it for him smile So let me rephrase that: Thanks for lunch! One Pearl Bank

Avatar_small
Robinjack 说:
2020年3月09日 22:59

you have a very excellent weblog here! do you wish to earn some invite posts on my own weblog? Kent Ridge Hill Residences Floor Plan

Avatar_small
Robinjack 说:
2020年3月09日 22:59

By how you compose, an individual appear to be an expert author. The Landmark Showflat

Avatar_small
Robinjack 说:
2020年3月09日 22:59

This website online can be a stroll-by means of for all the data you needed about this and didn’t know who to ask. Glimpse here, and you’ll undoubtedly uncover it. The Linq Floor Plan

Avatar_small
Robinjack 说:
2020年3月09日 22:59

Very exciting topic, warm regards for advertisment. “Let us never negotiate out of fear. But let us never fear to negotiate.” by John Fitzgerald Kennedy.. The Landmark Showflat

Avatar_small
niche backlinks 说:
2020年3月11日 00:55

A waterfall is an area where water flows over a vertical drop or a series of steep drops in the course of a stream or river. Waterfalls also occur where meltwater drops over the edge of a tabular iceberg or ice shelf.

Avatar_small
Computer monitoring 说:
2020年3月15日 20:01

This website does not display appropriately on my blackberry – you might wanna try and repair that

Avatar_small
oscillating multi to 说:
2020年3月15日 20:01

I don’t usually comment but I gotta tell appreciate it for the post on this amazing one : D.

Avatar_small
Robinjack 说:
2020年3月17日 16:10

At some point you are going to have a funeral, it is important that you make that as easy for your family as possible, by reducing not only the financial burden but also the emotional stress.   Direct Cremation

Avatar_small
One Pearl Bank 说:
2020年3月17日 21:34

Thank you for sharing excellent information. Your website is very cool. I am impressed by the info that you?ve on this website. It reveals how nicely you understand this subject. Bookmarked this web page, will come back for more articles.

Avatar_small
Avenue South Residen 说:
2020年3月17日 21:34

I discovered your blog site on google and appearance a couple of your early posts. Maintain the great operate. I recently additional your Feed to my MSN News Reader. Seeking forward to reading a lot more within you down the line!…

Avatar_small
The Avenir 说:
2020年3月17日 21:35

Excellent and really interesting blog. I really am into blogs that have to do with building muscle, so this is refreshing to me to see what you have here. Keep it going! force factor

Avatar_small
Hyll On Holland 说:
2020年3月17日 21:35

It’s perfect time to make some plans for the future and it is time to be happy. I’ve read this post and if I could I wish to suggest you few interesting things or suggestions. Perhaps you could write next articles referring to this article. I want to read more things about it!

Avatar_small
Robinjack 说:
2020年3月19日 20:23

So, if you do choose to take a fish oil supplement, you also need to supplement with another plant-based Omega 3 and Omega 6 blend, otherwise you will not have enough of the balanced essential fats, which are the foundation fats of health.   tackle box

Avatar_small
amber park 说:
2020年3月20日 17:42

~almost everyone in our family have hypertension, this disease is very common among older people“

Avatar_small
treasure at tampines 说:
2020年3月20日 17:42

we use big wall calendars on our offices, big wall calendars are easier to read.

Avatar_small
Robinjack 说:
2020年3月27日 22:59

Some Powerball winners share their secrets on this matter, one of which is the use a software package that has the ability to analyze the odds according to the history of winning numbers drawn in the past.   메이저놀이터

Avatar_small
Robinjack 说:
2020年3月27日 22:59

The focus on the customer (which is the basis for a relational existence) runs across certain concepts: price, quality, innovation, reliability of product, reliability of associated service and brand reputation.   Moments with Jenny

Avatar_small
Robinjack 说:
2020年3月27日 23:59

Increasing the longevity of your home and its fixtures and amenities comes from regular cleaning, upkeep and maintenance.   daglig städning

Avatar_small
zeeshan 说:
2020年3月28日 15:43

For those who suspect an employee of any underhandedness, or a spouse or partner of cheating, or even a child of lying about the use of drugs or sex, spy on cell phone software can reveal the truth about their actions.   check these guys out

Avatar_small
amber park 说:
2020年3月28日 21:01

I didn’t feel like there was really any closure or idea where it was going and was a little disappointed with it.

Avatar_small
treasure at tampines 说:
2020年3月28日 21:02

It??s really a cool and useful piece of information. I am happy that you simply shared this useful info with us. Please keep us informed like this. Thank you for sharing.

Avatar_small
autocad training in 说:
2020年3月29日 12:30

Ducat is one of the best autocad training institute in noida with 100% placement support. Ducat has well defined course modules and training sessions for students. At Ducat Autocad training is conducted during day time classes, weekend classes, evening batch classes and fast track training classes.

Avatar_small
Abhay Digital Market 说:
2020年3月29日 12:31

It’s nearly impossible to find educated people for this topic, but you sound like you know what you’re talking about!


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter