Skip to content

Commit

Permalink
actualizacion
Browse files Browse the repository at this point in the history
  • Loading branch information
kenshinsamue committed Apr 24, 2019
1 parent a6dd68c commit 70a9e4d
Show file tree
Hide file tree
Showing 32 changed files with 252 additions and 85 deletions.
2 changes: 1 addition & 1 deletion diffie_hellman/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/gg.dll",
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/diffie_hellman.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
Expand Down
6 changes: 3 additions & 3 deletions diffie_hellman/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "process",
"args": [
"build",
"${workspaceFolder}/gg.csproj"
"${workspaceFolder}/diffie_hellman.csproj"
],
"problemMatcher": "$tsc"
},
Expand All @@ -17,7 +17,7 @@
"type": "process",
"args": [
"publish",
"${workspaceFolder}/gg.csproj"
"${workspaceFolder}/diffie_hellman.csproj"
],
"problemMatcher": "$tsc"
},
Expand All @@ -28,7 +28,7 @@
"args": [
"watch",
"run",
"${workspaceFolder}/gg.csproj"
"${workspaceFolder}/diffie_hellman.csproj"
],
"problemMatcher": "$tsc"
}
Expand Down
145 changes: 113 additions & 32 deletions diffie_hellman/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,58 +41,139 @@ void recursivo(){

class diffie{

int alpha,p,xA,xB,yA,yB,kA,kB;
int alpha,p;
int[] X,Y,K,K2;
exponente mi_exp;
public diffie(int Alpha, int P,int Xa,int Xb){

public diffie(int Alpha, int P,int usuarios){

alpha=Alpha;
p=P;
xA=Xa;
xB=Xb;
X= new int [usuarios];
Y= new int [usuarios];
K= new int [usuarios];
K2 = new int [usuarios];

for(int i=0;i<usuarios;i++){
Console.WriteLine("Introduzca el valor del usuario: "+i);
X[i]=Convert.ToInt32(Console.ReadLine());
}

mi_exp= new exponente(alpha,xA,p);
yA=mi_exp.get_x();
Console.WriteLine("Ya = "+yA);
Console.Clear();
Console.WriteLine("Primo: "+p);
Console.WriteLine("Alpha: "+alpha);
Console.WriteLine("\n-----------------------------------------");
for(int i=0;i<usuarios;i++){
Console.WriteLine("X"+i+" = "+X[i]);
}

mi_exp=new exponente(alpha,xB,p);
yB=mi_exp.get_x();
Console.WriteLine("Yb = "+yB);
Console.WriteLine("-----------------------------------------");
for(int i=0;i<usuarios;i++){

mi_exp=new exponente(yB,xA,p);
kA=mi_exp.get_x();
Console.WriteLine("Ka = "+kA);
mi_exp = new exponente(alpha,X[i],p);
Y[i]=mi_exp.get_x();
Console.WriteLine("Y"+i+" = "+Y[i]);
}
Console.WriteLine("-----------------------------------------");
for(int i=0;i<usuarios;i++){


mi_exp = new exponente(Y[((usuarios+i)+1)%usuarios],X[i],p);
K[i]=mi_exp.get_x();
mi_exp = new exponente(Y[((usuarios+i)-1)%usuarios],X[i],p);
K2[i]=mi_exp.get_x();
Console.WriteLine("K"+i+" = "+K[i]+" | K2"+i+" = "+K2[i]);
}

}
public diffie(int Alpha, int P,int Xa,int Xb){
alpha=Alpha;
p=P;
X=new int [2];
Y=new int [2];
K=new int [2];
X[0]=Xa;
X[1]=Xb;


mi_exp =new exponente(yA,xB,p);
kB=mi_exp.get_x();
Console.WriteLine("Kb = "+kB);
mi_exp= new exponente(alpha,X[0],p);
Y[0]=mi_exp.get_x();
Console.WriteLine("Ya = "+Y[0]);


mi_exp= new exponente(alpha,X[1],p);
Y[1]=mi_exp.get_x();
Console.WriteLine("Yb = "+Y[1]);

mi_exp=new exponente(Y[1],X[0],p);
K[0]=mi_exp.get_x();
Console.WriteLine("Ka = "+K[0]);

mi_exp = new exponente(Y[0],X[1],p);
K[1]=mi_exp.get_x();
Console.WriteLine("Kb = "+K[1]);
}

}

static bool is_prime(int a){
int divisor=1,divisores=0;

do{
if(a%divisor==0){
divisores++;
}
divisor++;

}while(divisor<=a);
if(divisores==2)
return true;
else
return false;
}
static void Main(string[] args)
{
int p=0,a=0,Xa=0,Xb=0;

Console.WriteLine("Introduzca un numero primo: ");
p= Convert.ToInt32( Console.ReadLine());

int opt=0,n_user=0;
do{
Console.WriteLine("Introduzca un numero primo: ");
p= Convert.ToInt32( Console.ReadLine());
}while(is_prime(p)==false);

do{
Console.WriteLine("introduzca le valor alpha :");
a=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("introduzca le valor alpha :");
a=Convert.ToInt32(Console.ReadLine());
}while(a>=p || a<=0);

Console.WriteLine("introduzca el valor Xa: ");
Xa=Convert.ToInt32(Console.ReadLine());
do{
Console.WriteLine("Introduzca una opcion: \n1.Dos usuarios\n2.Varios usuarios");
opt=Convert.ToInt32(Console.ReadLine());
}while(opt!=1 && opt !=2 );

if(opt==1){
Console.WriteLine("introduzca el valor Xa: ");
Xa=Convert.ToInt32(Console.ReadLine());

Console.WriteLine("introduzca el valor Xb: ");
Xb=Convert.ToInt32(Console.ReadLine());

Console.Clear();

Console.WriteLine("introduzca el valor Xb: ");
Xb=Convert.ToInt32(Console.ReadLine());

Console.Clear();
Console.WriteLine("Xa = "+Xa);

Console.WriteLine("Xb = "+Xb);
diffie hellman = new diffie(a,p,Xa,Xb);
}
if(opt==2){
do{
Console.WriteLine("Cuantos usuarios va a introducir(numero par): ");
n_user=Convert.ToInt32(Console.ReadLine());

}while( n_user<=0 );

diffie hellman= new diffie(a,p,n_user);

Console.WriteLine("Xa = "+Xa);

Console.WriteLine("Xb = "+Xb);
diffie hellman = new diffie(a,p,Xa,Xb);
}


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v2.2": {
"gg/1.0.0": {
"diffie_hellman/1.0.0": {
"runtime": {
"gg.dll": {}
"diffie_hellman.dll": {}
}
}
}
},
"libraries": {
"gg/1.0.0": {
"diffie_hellman/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed diffie_hellman/bin/Debug/netcoreapp2.2/gg.dll
Binary file not shown.
Binary file removed diffie_hellman/bin/Debug/netcoreapp2.2/gg.pdb
Binary file not shown.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("gg")]
[assembly: System.Reflection.AssemblyCompanyAttribute("diffie_hellman")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("gg")]
[assembly: System.Reflection.AssemblyTitleAttribute("gg")]
[assembly: System.Reflection.AssemblyProductAttribute("diffie_hellman")]
[assembly: System.Reflection.AssemblyTitleAttribute("diffie_hellman")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a42f386be3b9f886df17f76645637962c12aeb52
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/bin/Debug/netcoreapp2.2/diffie_hellman.deps.json
/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/bin/Debug/netcoreapp2.2/diffie_hellman.runtimeconfig.json
/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/bin/Debug/netcoreapp2.2/diffie_hellman.runtimeconfig.dev.json
/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/bin/Debug/netcoreapp2.2/diffie_hellman.dll
/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/bin/Debug/netcoreapp2.2/diffie_hellman.pdb
/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/obj/Debug/netcoreapp2.2/diffie_hellman.csprojAssemblyReference.cache
/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/obj/Debug/netcoreapp2.2/diffie_hellman.csproj.CoreCompileInputs.cache
/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/obj/Debug/netcoreapp2.2/diffie_hellman.AssemblyInfoInputs.cache
/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/obj/Debug/netcoreapp2.2/diffie_hellman.AssemblyInfo.cs
/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/obj/Debug/netcoreapp2.2/diffie_hellman.dll
/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/obj/Debug/netcoreapp2.2/diffie_hellman.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file removed diffie_hellman/obj/Debug/netcoreapp2.2/gg.dll
Binary file not shown.
Binary file removed diffie_hellman/obj/Debug/netcoreapp2.2/gg.pdb
Binary file not shown.
14 changes: 0 additions & 14 deletions diffie_hellman/obj/Debug/netcoreapp2.2/project.razor.json

This file was deleted.

5 changes: 5 additions & 0 deletions diffie_hellman/obj/diffie_hellman.csproj.nuget.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": 1,
"dgSpecHash": "l4LnIP2ZOVL/PauKKYo2tOhKMpTZvZaNg5rm/yQqHpBtkQXt+EZTbZN5yCaodazDK3dbpGKMyUhD67G2vu66fQ==",
"success": true
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"format": 1,
"restore": {
"/home/k1k4ss0/Downloads/gg/gg.csproj": {}
"/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/diffie_hellman.csproj": {}
},
"projects": {
"/home/k1k4ss0/Downloads/gg/gg.csproj": {
"/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/diffie_hellman.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/k1k4ss0/Downloads/gg/gg.csproj",
"projectName": "gg",
"projectPath": "/home/k1k4ss0/Downloads/gg/gg.csproj",
"projectUniqueName": "/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/diffie_hellman.csproj",
"projectName": "diffie_hellman",
"projectPath": "/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/diffie_hellman.csproj",
"packagesPath": "/home/k1k4ss0/.nuget/packages/",
"outputPath": "/home/k1k4ss0/Downloads/gg/obj/",
"outputPath": "/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/share/dotnet/sdk/NuGetFallbackFolder"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">/home/k1k4ss0/Downloads/gg/obj/project.assets.json</ProjectAssetsFile>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/obj/project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/k1k4ss0/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/k1k4ss0/.nuget/packages/;/usr/share/dotnet/sdk/NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">4.9.4</NuGetToolVersion>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.0.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
Expand Down
5 changes: 0 additions & 5 deletions diffie_hellman/obj/gg.csproj.nuget.cache

This file was deleted.

8 changes: 4 additions & 4 deletions diffie_hellman/obj/project.assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -692,11 +692,11 @@
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/k1k4ss0/Downloads/gg/gg.csproj",
"projectName": "gg",
"projectPath": "/home/k1k4ss0/Downloads/gg/gg.csproj",
"projectUniqueName": "/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/diffie_hellman.csproj",
"projectName": "diffie_hellman",
"projectPath": "/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/diffie_hellman.csproj",
"packagesPath": "/home/k1k4ss0/.nuget/packages/",
"outputPath": "/home/k1k4ss0/Downloads/gg/obj/",
"outputPath": "/home/k1k4ss0/Desktop/Seguridad_informatica/diffie_hellman/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/share/dotnet/sdk/NuGetFallbackFolder"
Expand Down
Loading

0 comments on commit 70a9e4d

Please sign in to comment.