- 浏览: 2551033 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
GCM(1)Get Start
1. Getting Started
Follow the document to create Google APIs Console project
The URL are as follow:
https://code.google.com/apis/console/
I click create project to create an API project and then rename it to easymessagepush.
Take a note of my project number ***
Enabling the GCM Service
Click on the Service tab menu and turn on the 'Google Cloud Messaging for Android'
Obtaining an API Key
Select the tab menu, 'API Access'
I just select the 3 one by one
Create new Server key
Create new Browser key
Create new Android key
I did not type in something, I want make them allowed for any app, any IP and any referer right now, maybe I will change that in the future.
Install the Helper Libraries
From the SDK Manager on eclipse, find the menu
Extras ---> Google Cloud Messaging for Android Library
Install this feature, it will create a GCM directory under my SDK ROOT/extras/google/
For me, that is /opt/android-sdk/extras/google
Everything will be in this directory /opt/android-sdk/extras/google/gcm
Writing the Android Application
Step1: Copy the gcm.jar file into our application classpath
find the gcm.jar from here gcm-client/dist
My project is managed by MAVEN, so I decide to add this in pom.xml
<dependency>
<groupId>com.google.android</groupId>
<artifactId>gcm</artifactId>
<version>1.0.2</version>
</dependency>
Step2: Make the following changes in the application's Android manifest
1. GCM requires Android 2.2 or later, make sure we have this kind of line in AndroidManifest.xml
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15"/>
2. Declare and use a custom permission so only this application can receive GCM message:
<permission android:name="com.sillycat.easyrestclientandroid.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission
android:name="android.permission.INTERNET"/>
<uses-permission
android:name="com.sillycat.easyrestclientandroid.permission.C2D_MESSAGE"/>
The package name com.sillycat.easyrestclientandroid should be the same as
<manifestxmlns:android="http://schemas.android.com/apk/res/android"
package="com.sillycat.easyrestclientandroid" …snip…
3. Add the following permissions
<!-- App receives GCM messages. -->
<uses-permissionandroid:name="com.google.android.c2dm.permission.RECEIVE"/>
<!-- GCM connects to Google Services. -->
<uses-permissionandroid:name="android.permission.INTERNET"/>
<!-- GCM requires a Google account. -->
<uses-permissionandroid:name="android.permission.GET_ACCOUNTS"/>
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permissionandroid:name="android.permission.WAKE_LOCK"/>
4. Add the following broadcast receiver
<application>
…snip...
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action
android:name="com.google.android.c2dm.intent.RECEIVE"/>
<action
android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category
android:name="com.sillycat.easyrestclientandroid" />
</intent-filter>
</receiver>
…snip…
</application>
This broadcast receiver is responsible for handling the 2 intents that can be sent by GCM.
com.google.android.c2dm.intent.RECEIVE
com.google.android.c2dm.intent.REGISTRATION
These should be defined in the manifest(rather than programmatically) so that these intents can be received even if the application is not running.
5. Add the following intent service
<application>
…snip..
<service android:name=".GCMIntentService" />
…snip...
</application>
This intent service will be called by the GCMBroadcastReceiver.
Step 3: Write the GCMIntentService class
The detail of the project is in the sample EasyRestClientAndroid project.
Writing the Server-side Application
The detail is in project 4mymessage project.
References:
https://developer.android.com/google/gcm/gcm.html
https://developer.android.com/google/gcm/gs.html
1. Getting Started
Follow the document to create Google APIs Console project
The URL are as follow:
https://code.google.com/apis/console/
I click create project to create an API project and then rename it to easymessagepush.
Take a note of my project number ***
Enabling the GCM Service
Click on the Service tab menu and turn on the 'Google Cloud Messaging for Android'
Obtaining an API Key
Select the tab menu, 'API Access'
I just select the 3 one by one
Create new Server key
Create new Browser key
Create new Android key
I did not type in something, I want make them allowed for any app, any IP and any referer right now, maybe I will change that in the future.
Install the Helper Libraries
From the SDK Manager on eclipse, find the menu
Extras ---> Google Cloud Messaging for Android Library
Install this feature, it will create a GCM directory under my SDK ROOT/extras/google/
For me, that is /opt/android-sdk/extras/google
Everything will be in this directory /opt/android-sdk/extras/google/gcm
Writing the Android Application
Step1: Copy the gcm.jar file into our application classpath
find the gcm.jar from here gcm-client/dist
My project is managed by MAVEN, so I decide to add this in pom.xml
<dependency>
<groupId>com.google.android</groupId>
<artifactId>gcm</artifactId>
<version>1.0.2</version>
</dependency>
Step2: Make the following changes in the application's Android manifest
1. GCM requires Android 2.2 or later, make sure we have this kind of line in AndroidManifest.xml
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15"/>
2. Declare and use a custom permission so only this application can receive GCM message:
<permission android:name="com.sillycat.easyrestclientandroid.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission
android:name="android.permission.INTERNET"/>
<uses-permission
android:name="com.sillycat.easyrestclientandroid.permission.C2D_MESSAGE"/>
The package name com.sillycat.easyrestclientandroid should be the same as
<manifestxmlns:android="http://schemas.android.com/apk/res/android"
package="com.sillycat.easyrestclientandroid" …snip…
3. Add the following permissions
<!-- App receives GCM messages. -->
<uses-permissionandroid:name="com.google.android.c2dm.permission.RECEIVE"/>
<!-- GCM connects to Google Services. -->
<uses-permissionandroid:name="android.permission.INTERNET"/>
<!-- GCM requires a Google account. -->
<uses-permissionandroid:name="android.permission.GET_ACCOUNTS"/>
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permissionandroid:name="android.permission.WAKE_LOCK"/>
4. Add the following broadcast receiver
<application>
…snip...
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action
android:name="com.google.android.c2dm.intent.RECEIVE"/>
<action
android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category
android:name="com.sillycat.easyrestclientandroid" />
</intent-filter>
</receiver>
…snip…
</application>
This broadcast receiver is responsible for handling the 2 intents that can be sent by GCM.
com.google.android.c2dm.intent.RECEIVE
com.google.android.c2dm.intent.REGISTRATION
These should be defined in the manifest(rather than programmatically) so that these intents can be received even if the application is not running.
5. Add the following intent service
<application>
…snip..
<service android:name=".GCMIntentService" />
…snip...
</application>
This intent service will be called by the GCMBroadcastReceiver.
Step 3: Write the GCMIntentService class
The detail of the project is in the sample EasyRestClientAndroid project.
Writing the Server-side Application
The detail is in project 4mymessage project.
References:
https://developer.android.com/google/gcm/gcm.html
https://developer.android.com/google/gcm/gs.html
发表评论
-
ionic UI(4)ionic2 framework - basic and components and native
2016-03-24 02:33 1261ionic UI(4)ionic2 framework - b ... -
ionic UI(3)TypeScript - handbook
2016-03-22 23:21 634ionic UI(3)TypeScript - handboo ... -
ionic UI(2)ionic2 framework - TypeScript - tutorial
2016-03-22 06:52 1656ionic UI(2)ionic2 framework - T ... -
Parse and Heroku Service(3)Parse Server and Parse Dashboard
2016-03-22 06:30 967Parse and Heroku Service(3)Pars ... -
Parse and Heroku Service(2)Mail Templates and Push Notification
2016-03-22 02:45 583Parse and Heroku Service(2)Mail ... -
ionic UI(1)Introduction
2016-03-19 03:18 722ionic UI(1)Introduction 1 Inst ... -
Parse and Heroku Service(1)Heroku Installation and Play
2016-03-19 00:13 824Parse and Heroic Service(1)Hero ... -
Hybrid(5)Customize Meteor Directly Google Login
2015-09-01 02:33 910Hybrid(5)Customize Meteor Direc ... -
Hybrid(4)Favorite Places - Google Login
2015-09-01 02:02 1341Hybrid(4)Favorite Places - Goog ... -
Hybrid(3)More Meteor Example - Social
2015-08-11 05:04 756Hybrid(3)More Meteor Example - ... -
Hybrid(2)meteor Running Android and iOS
2015-07-28 23:59 1049Hybrid(2)meteor Running Android ... -
Create the Google Play Account
2015-07-18 06:42 1101Create the Google Play Account ... -
Secure REST API and Mobile(1)Document Read and Understand OAUTH2
2015-07-14 00:36 764Secure REST API and Mobile(1)Do ... -
Screen Size and Web Design
2015-07-11 01:11 725Screen Size and Web Design iPh ... -
Hybrid(1)ionic Cordova meteor
2015-06-25 05:49 471Hybrid(1)ionic Cordova meteor ... -
Android Fire Project(1)Recall Env and Knowledge
2015-02-11 12:28 686Android Fire Project(1)Recall ... -
Android Content Framework(1)Concept
2014-06-14 13:54 1080Android Content Framework(1)Con ... -
Feel Android Studio(1)Install and Update Android Studio
2014-04-11 03:12 2029Feel Android Studio(1)Install a ... -
IOS7 App Development Essentials(2)iBeacon
2014-03-05 05:55 890IOS7 App Development Essentials ... -
IOS7 App Development Essentials(1) Persistent Store
2014-03-05 05:54 1327IOS7 App Development Essentials ...
相关推荐
1. **初始化向量(IV)**:在开始加密过程前,需要一个唯一的初始向量。IV通常与密钥一起决定密文的唯一性,但不需保密。 2. **加密过程**:AES加密操作是通过对128位的数据块进行多次迭代来完成的。在GCM模式下,每...
1. **初始化向量(IV)**:每个加密会话都需使用唯一的初始化向量,防止相同的明文在不同的会话中加密后得到相同的密文。 2. **CTR模式加密**:AES算法在CTR模式下,将数据块与一个计数值(通常结合了IV)进行异或...
高版本AES-GCM模式加密的Shiro漏洞利用1 高版本AES-GCM模式加密的Shiro漏洞利用1是指在Shiro框架中,使用高版本AES-GCM模式加密时出现的漏洞利用问题。Shiro框架在高版本中更换了加密算法,从AES-CBC换成了AES-GCM...
1. 初始化向量(IV):每个消息都有唯一的IV,以防止相同的明文产生相同的密文。 2. 密钥扩展:AES密钥通过特定算法扩展为多个轮密钥,用于加密过程中。 3. 计数器模式:使用IV和扩展的密钥生成一个伪随机流,与明文...
1. **AES加密引擎**:这是执行实际的AES加密和解密操作的核心部分,可能包括AES的快速实现,如AES-NI指令集优化。 2. **GCM模块**:负责处理计数器模式和伽罗华域计算,生成MAC并进行数据认证。 3. **SIV模块**:...
1. **AES基础知识** AES分为128位、192位和256位三种密钥长度,其中128位是默认且最常用的。它通过一系列复杂的数学运算(如替换、置换、混淆和扩散)对明文进行加密,形成密文。每个AES操作包含多个轮,每轮包括...
1. 启用 GCM(Enabling GCM):在 Android 应用中启用 GCM 服务,以便于服务器端可以发送消息。 2. 发送消息(Sending a message):服务器端发送消息到 GCM 服务器,GCM 服务器将消息转发到目标 Android 应用。 3. ...
### AES128加密算法的GCM工作模式详解 #### 引言 本文档主要介绍了一种名为Galois/Counter Mode(GCM)的高级加密标准(AES)的工作模式。GCM是一种高效的、可认证的加密技术,适用于高速硬件加密场景以及软件实现...
1. **移动设备**:运行着需要使用GCM服务的Android应用的设备。需满足以下条件之一:运行Android 2.2及以上版本且安装有Google Play Store,或具备Google API的Android 2.2虚拟机。若设备版本低于Android 4.0.4,则...
1. 项目源代码:这可能是一个完整的Android Studio项目,包含了必要的Java或Kotlin代码,展示了如何注册设备,接收GCM消息,并在用户界面显示这些消息。 2. 配置文件:可能包括AndroidManifest.xml,其中包含了GCM所...
1. AES-GCM结合了AES块加密和GCM模式。AES是用于加密的块密码,而GCM是一种用于认证加密的模式,它可以同时提供保密性和数据完整性。 2. GCM模式使用了一个称为nonce(数字唯一值)的输入,它是随机或伪随机生成的,...
主要是aes-gcm算法实现的code,详细描述gcm算法的各部分实现过程
1. **注册GCM**:首先,开发者需要在Google Developer Console中创建一个项目,并获取到Project Number(也称为Sender ID),这是每个应用在使用GCM时必须的唯一标识。 2. **配置AndroidManifest.xml**:在Android...
AesTestTool为加密软件,支持GCM 和 ECB两种模式 128bit秘钥 GCM算法是一个C++工程,“C++gcm算法工程”目录里面有源码 加密软件是用C#写的,所以把C++工程编译成了dll文件,由C#调用 “软件工程目录”文件夹是...
AES-GCM架构是一种加密技术,它结合了高级加密标准(AES)和伽罗瓦/计数器模式(GCM),旨在提供数据加密和身份验证。GCM由David A. McGrew和John Viega开发,是一个用于提供机密性和认证的对称块密码模式,它的特点...
GCM(Galois/Counter Mode)和GMAC(Galois Message Authentication Code)是密码学中的两种重要算法,主要用于数据加密和完整性校验。它们都基于AES(Advanced Encryption Standard,高级加密标准)算法,为现代...
1. **AES加密算法**:AES由一系列称为轮的处理组成,每轮包括字节代换、行位移、列混淆和轮密钥加法四个步骤。在128位版本中,有10轮加密过程,对于192位和256位版本则分别增加到12轮和14轮。 2. **Verilog HDL**:...
1. **AES模块**:这是执行AES加密的代码,可能会包括密钥扩展、加密和解密的函数。 2. **CTR模块**:这部分代码会处理计数器的递增和与密钥的异或操作,生成伪随机流。 3. **GHASH模块**:这里包含用于计算MAC的函数...
1. 密钥生成:首先,系统需要生成一个128位的密钥,用于加密和解密过程。密钥必须保持机密,只在安全的环境中生成和存储。 2. 初始化向量(IV):每个加密操作都需要一个唯一的IV,通常随机生成。IV不需保密,但不...
1. 使用计数器模式(CTR mode)对明文进行加密。 2. 对所有数据块(包括明文和任何附加的数据)应用通用哈希函数。 3. 将加密后的数据与哈希结果结合生成认证标签。 **解密过程:** 解密过程同样分为两步:首先...