Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - d3adly

#81
Para eso es el foro ayuda mutua  ;)
#82
Me alegro ayudarte, cualquier duda no vaciles en pedir ayuda.
#83
Hola @No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
Respecto a las funciones
La de generar un numero aleatorio podria quedar asi
Código: cpp

void GenerarNumero(int (&nArray)[4]){
srand(time(nullptr));
for(int i = 0; i < 4; i++){
int b = rand()%10;
        if(!EstaEnArreglo(b, nArray, i)){
        nArray[i] = b;
        } else {
i--;
}
    }
}


Y te explico la linea
Código: php
int (&nArray)[4]

Se le pasa por referencia un array de 4 enteros por eso el & antes del nombre de la variable nArray, asi cualquier modificacion a la variable dentro de la funcion se conserva al final de la misma.
Eso si, si le pasas un array mayor de cuatro te dara error de compilacion ya que esta esperando un array de 4. Para solucionar este problema y pasar un array de numero indefinido se puede emplear el uso de templates
Código: php
template<typename T, size_t N>


Y asi la funcion se podria modificar quedando asi
Código: php
void GenerarNumer(T (&nArray)[N])


Pero ya que este ejercicio requiere de 4 te queda de tarea el uso de templates ;D

La funcion para obtener el numero picas se podria implementar de la siguiente manera
Código: cpp
int NPicas(int nArrayA[], int nArrayB[]){
int iPicas = 0;
for( int l=0;l<4;l++){
for( int m=0;m<4;m++){
            if (nArrayA[l]==nArrayB[m]){
iPicas++;
            }
        }
    }
    return iPicas;
}

Esta funcion retorna un valor entero fijate el int antes de el nombre de la funcion, recibe como parametro dos arrays nArraA y nArraB. Se declara primero la variable iPicas y se inicializa a 0 para poder ir incrementando su valor. Luego se compara cada elemento verificando si se encuentra en el array, de ser asi se incrementa la variable local iPicas. Al finalizar la comparacion la function retorna el valor de la variable local iPicas.

La funcion para obtener el numero de fijas se puede implementar de la siguiente manera
Código: cpp

int NFijas(int nArrayA[], int nArrayB[]){
int iFijas = 0;
for( int l=0;l<4;l++){
        if (nArrayA[l]==nArrayB[l]){
iFijas++;
        }
    }
return iFijas;
}

Esta funcion al igual que la otra retorna un valor entero y  recibe dos array como parametros nArraA y nArraB. A diferencia de la anterior solo se hace un for ya que la posicion del numero debe ser exacto, al igual que la funcion anterior se declara una variable local llamada iFijas que va incrementando segun se encuentre una concordancia en el bucle. Al final la funcion retorna el valor local de iFijas.

Y por ultimo la funcion para verificar si el numero generado aleatoriamente ya se encuentra en el arreglo
Código: cpp

bool EstaEnArreglo(int iNumero, int nArray[], int iArrTam){
for(int i = 0; i < iArrTam; i++){
if(iNumero == nArray[i]){
return true;
}
}
return false;
}

Esta funcion retorna un valor del tipo bool, osea verdadero o falso. Recibe como parametro el numero a verificar iNumero, el array en el cual verificar si existe el numero proporcionado (nArray) y el tamaño actual de los valores seteados dentro del arreglo, para evitar recorrer el arreglo innecesariamente iArrTam. Si el numero ya se encuentra retorna true, de lo contrario finaliza el bucle y retorna false.

Con lo cual tu codigo podria quedar de la siguiente manera
Código: cpp

#include <iostream>
#include <ctime>
#include <cstdlib>

bool EstaEnArreglo(int iNumero, int nArray[], int iArrTam){
for(int i = 0; i < iArrTam; i++){
if(iNumero == nArray[i]){
return true;
}
}
return false;
}

void GenerarNumero(int (&nArray)[4]){
srand(time(nullptr));
for(int i = 0; i < 4; i++){
int b = rand()%10;
        if(!EstaEnArreglo(b, nArray, i)){
        nArray[i] = b;
        } else {
i--;
}
     
    }
}

int NPicas(int nArrayA[], int nArrayB[]){
int iPicas = 0;
for( int l=0;l<4;l++){
for( int m=0;m<4;m++){
            if (nArrayA[l]==nArrayB[m]){
iPicas++;
            }
        }
    }
    return iPicas;
}

int NFijas(int nArrayA[], int nArrayB[]){
int iFijas = 0;
for( int l=0;l<4;l++){
        if (nArrayA[l]==nArrayB[l]){
iFijas++;
        }
    }
return iFijas;
}

int main(int argc, char** argv) {
     
       int numa[4];
       int nume[4];
       int fijas = 0,picas = 0,num = 0, i = 0;
       GenerarNumero(numa);
       
       //Esto deberia de ocultarse para no hacer visible el numero a adivinar
   //**************************
       for( i = 0; i < 4; i++){
           std::cout<<numa[i]<<' ';
       }
       std::cout<<'\n';
       //***************************
       std::cout<<"JUEGO PICAS Y FIJAS\n\n";
        for( i = 0; i < 12; i++){
           std::cout<<"Ingrese cada digito seguido de un enter\n";
           for( int j = 0; j < 4; j++){
              std::cout<<j+1<<".- ";
              scanf("%i",&nume[j]);
}
     
picas = 0; fijas = 0;       
     
fijas = NFijas(numa, nume);
picas = NPicas(numa, nume);
picas-= fijas;
         
           if(fijas == 4) break;
          num++;
          std::cout<<"intentos: "<<num<<" fijas: "<<fijas<<", picas: "<<picas<<"\n";
       }
       if(num < 4) std::cout<<"Bien, Excelente\n";
       else if(num <  8 ) std::cout<<"Bien, Aceptable\n";
       else if(num < 12) std::cout<<"Bien, Regular\n";
       else std::cout<<"Mal, este juego como que no es para ti\n";
     
        for( i = 0; i < 4; i++){
           std::cout<<numa[i]<<' ';
}
std::cout<<'\n';
       return 0;
    }


Por ultimo te si te apasiona la programacion te recomiendo leer mucho y sobre todo practicar, espero te funcione.

Saludos.
#84
Mi sugerencia seria que probaras otra version del juego ya que posiblemente sea un problema de versiones wine/sims.
#85
Si estas seguro de tener todas las dependencias para correr el juego usando wine, puedes probar a ejecutarlo con wine-development en lugar de wine
/usr/bin/wine-development /home/manuel/Games/the-sims/drive_c/Program Files/Maxis/The Sims/Sims.exe -r1024x768 -skip_intro -skip_verify
Si no lo tienes instalalo con sudo apt-get install wine-development
Tambien verifica de que arquitectura es el juego ya podria ser tambien un problema de compatibilidad.
#86
Segun dices se debe el ejecutable que no es reconocido como tal por wine
Que version tienes?, ya que segun la web de wine corre bien en la version NoCD, puedes revisar  No tienes permitido ver los links. Registrarse o Entrar a mi cuenta  para ver los entornos en los cuales ha corrido y las fallas conocidas.
#87
Hola @lemos.ema.
La primera correcion seia en esta linea
Citar$url2 .= ($object_return->node->shortcode);
ya que seguira agregando a la url el nuevo short code obtenido y no obtendras nuevos datos, por lo cual antes de concatenar el short code debes resetear la variable al valor inicial No tienes permitido ver los links. Registrarse o Entrar a mi cuenta.
Y segun No tienes permitido ver los links. Registrarse o Entrar a mi cuenta le pasas el parametro true para obtener un array asociativo en lugar de un objeto
Código: php

<?php
ini_set('max_execution_time', 0);
$baseUrl = "https://www.instagram.com/explore/tags/comida/?__a=1";
$url = $baseUrl;
$baseUrl2 = "https://www.instagram.com/p/";
$url2 = $baseUrl2;

while(1) {
    $file = fopen("links.txt","a");
    $json = (object) json_decode(file_get_contents($url));
    foreach($json->{'graphql'}->hashtag->edge_hashtag_to_media->edges as $object_return){
        var_dump($object_return->node->shortcode);
        echo "{$object_return->node->shortcode}\n";
        fwrite($file, $object_return->node->shortcode);
        fwrite($file,"\n");
        $url2 = $baseUrl2;  //Aqui se resetea la variable
        $url2 .= ($object_return->node->shortcode);
        $url2 .= "/?__a=1";
        echo "{$url2}\n";
        $json2 = json_decode(file_get_contents($url2), true);   //En lugar de obtener un objeto se obtiene un array asociativo
        $full_name = $json2['graphql']['shortcode_media']['owner']['full_name']."\n";
        $followed_by = $json2['graphql']['shortcode_media']['owner']['edge_followed_by']['count']."\n";
        //Ahora full_name y followed_by contienen los datos deseados
        fwrite($file, $full_name);
        fwrite($file,"\n");
        fwrite($file, $followed_by);
        fwrite($file,"\n");
    }

    fclose($file);
    // Deben modificar la variable $URL y acceder correctamente a ella
    if(!$json->{'graphql'}->hashtag->edge_hashtag_to_media->page_info->has_next_page) break;
    $url = $baseUrl.'&max_id='.$json->{'graphql'}->hashtag->edge_hashtag_to_media->page_info->end_cursor;
}


Te aconsejo que leas bien la documentacion ante cualquier error, posiblemente se te haga facil solucionar el problema, de lo contrario no dudes en preguntar.
Espero haber resuelto tus dudas, saludos.
#88
Les comparto un simple codigo para ofuscar variables, y asi no escribir directamente ciertas palabras que deseemos harcodear en el programa para que no sean visibles por programas como strings o similares, no es para informacion sensible, es por pura diversion y ocultacion de palabras, espere los guste.

Código: c

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>

void HC(const char *input, int len){
     srand(time(NULL));
     char tmpbuff1[10];
     char tmpbuff[10240];
     memset(tmpbuff, '\0', 10240);
     memset(tmpbuff1, '\0', 10);
    //Para generar nombre de variable aleatorio
     char keys[] = {'_', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z','a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3' ,'4', '5', '6', '7', '8', '9'};
     int i = 0, a = 0, b = 0, c = 1;
     for (; i < 7; i ++){
        tmpbuff1[i] = keys[rand() % 63];
     }
     snprintf(tmpbuff, 50, "unsigned char %s[%i] = { ", tmpbuff1, len);
     for(a = 0, b = 0; a<len; a++){
         b = input[a];
         b ^= 0xEC;
         b ^= a;
         char tmp[50];
         if(a == (len - 1)) {
             snprintf(tmp, 15, "0x%x };", b);
             strncat(tmpbuff, tmp, strlen(tmp));
             break;
         }
         if (c++ == 12){
             snprintf(tmp, 15, "0x%x,\n   ", b);
             strcat(tmpbuff, tmp);
             c = 1;
         }else{
             snprintf(tmp, 15, "0x%x, ", b);
             strcat(tmpbuff, tmp);
         }
     }
     printf("Aqui esta tu codigo\n\n%s\n\n", tmpbuff);
}


/*Funcion para "decifrar" variable y usarla
unsigned char var_name[6] = { 0x9e, 0x8c, 0x80, 0x8b, 0x87, 0x84 };   <<   random
char *new_var = malloc(sizeof(char) * 7);
HCD(var_name, 6, &new_var);
ahora new_var = "random"
*/
void HCD(const char *input, int len, char **outp)
{
    int a = 0, b = 0;
     char outvar[len];
     memset(outvar, '\0', len);
     for(a = 0, b = 0; a<len; a++){
         b = input[a];
         b ^= 0xEC;
         b ^= a;
         strcat(outvar, (char*)&b);
     }
     strncpy(*outp, outvar, len);
}

int main(int argc, char **argv)
{
  HC(argv[1], strlen(argv[1]));
  return 0;
}

#89
Hola @No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
Citarhora con mi duda, el SSID es el nombre de la red?
Asi es, el SSID es el nombre la red o punto de acceso.
#90
Super interesante, futuros codigos solo requeriran
"""Create Application no bugs/leaks fast nice ui"""   ;D
#91
C / C++ / Simple Cipher
Mayo 18, 2020, 11:45:13 PM
Hola les comparto un cipher sencillo que hice, basado en rot13 y xor a diferencia que rota 128 caracteres y este numero aumenta dependiendo de la longitud de la informacion a modificar, antes pasa por base64 para poder trabajar con caracteres imprimibles, logrando (aun no probado) trabajar con datos binarios, tiene varios errores y posiblemente mal manejo de memoria por lo cual agradezco sus aportes/correcciones/sugerencias.

Código: c++

#include<iostream>
#include<string>
#include<cstring>
class b64{
   public:
size_t b64_encoded_size(size_t inlen){
size_t ret = inlen;
if(inlen % 3 != 0){
ret += 3 - (inlen % 3);
}
ret /= 3;
ret *= 4;
return ret;
}
size_t b64_decoded_size(const char *in){
size_t len, ret, i;
if(in == nullptr){
return 0;
}
len = std::string(in).length();
ret = len / 4 * 3;
for(i = len; i-->0;){
if(in[i] == '='){
ret--;
} else {
break;
}
}
return ret;
}
int b64_valid_char(char c){
        if (c >= '0' && c <= '9'){
                return 1;
}
        if (c >= 'A' && c <= 'Z'){
                return 1;
}
        if (c >= 'a' && c <= 'z'){
                return 1;
}
        if (c == '+' || c == '/' || c == '='){
                return 1;
}
        return 0;
}
char *b64_encode(const unsigned char *in, size_t len){
const char b64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
char *out;
size_t elen, i, j, v;
if(in == nullptr || len == 0){
return nullptr;
}
elen = b64_encoded_size(len);
out = new char[elen+1];
out[elen] = '\0';
for(i = 0, j = 0; i < len; i += 3, j += 4){
v = in[i];
v = i + 1 < len ? v << 8 | in[i+1] : v << 8;
v = i + 2 < len ? v << 8 | in[i+2] : v << 8;
out[j]     = b64chars[(v >> 18) & 0x3F];
out[j + 1] = b64chars[(v >> 12) & 0x3F];
if(i + 1 < len){
out[j + 2] = b64chars[(v >> 6) & 0x3F];
}else{
out[j + 2] = '=';
}
if(i + 2 < len){
out[j + 3] = b64chars[v & 0x3F];
}else{
out[j + 3] = '=';
}
}
return out;
}

int b64_decode(const char *in, unsigned char *out, size_t outlen){
int b64_t[] = { 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58,
        59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5,
        6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
        21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28,
        29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
        43, 44, 45, 46, 47, 48, 49, 50, 51 };
size_t len, i, j;
int v;
if(in == nullptr || out == nullptr){
return 0;
}
len = std::string(in).length();
if(outlen < b64_decoded_size(in) || len % 4 != 0){
return 0;
}
for(i = 0; i < len; i++){
if(!b64_valid_char(in[i])){
return 0;
}
}
for(i = 0, j = 0; i < len; i += 4, j += 3){
v = b64_t[in[i] - 43];
v = (v << 6) | b64_t[in[i + 1] - 43];
v = in[i + 2] == '=' ? v << 6 : (v << 6) | b64_t[in[i + 2] - 43];
v = in[i + 3] == '=' ? v << 6 : (v << 6) | b64_t[in[i + 3] - 43];

out[j] = (v >> 16) & 0xFF;
if(in[i + 2] != '='){
out[j + 1] = (v >> 8 ) & 0xFF;
}
if(in[i + 3] != '='){
out[j + 2] = v & 0xFF;
}
}
return 1;
}
};

class LCipher: public b64{
   private:
int calc(char c, int complex = 0){
int tmp = c, count = 0;
while(1){
if(count++ == (128+complex)){break;}
if(tmp++ == 126){ tmp = 32;}
}
return tmp;

}
int r_calc(char c, int complex = 0){
int tmp = c, count = 128+complex;
while(1){
if(count-- == 0){break;}
if(tmp-- == 32){tmp = 126;}
}
return tmp;
}
std::string LOL(const std::string& message){
std::string final = "";
int tcplx = 0;
for(char c : message){
char tmp = calc(c, ++tcplx);
for(char x : this->password){
tmp ^= x;
}
final += tmp;
}
return final;
}
std::string OLO(const std::string& message){
std::string final = "";
int tcplx = 0;
for(char c : message){
for(char x : this->password){
c ^= x;
}
final += r_calc(c,++tcplx);
}
return final;
}
char *b64_e(const unsigned char* message){
int len = std::string((char *)message).length();
char *out = b64_encode(message, len);
        return out;
}
char *b64_d(const char* message){
size_t outlen = b64_decoded_size(message);
unsigned char *output = new unsigned char[outlen];
b64_decode(message, output, outlen);
return (char *)output;
}
std::string password;
   public:
LCipher(): password("default"){}
        LCipher(std::string p): password(p){}

int Cipher(char*& data, char **output){
char *tmp = b64_e((const unsigned char *)data);
std::string result = LOL(std::string(tmp));
delete tmp;
size_t rlen = result.length();
*output = new char[rlen + 2];
if(*output == nullptr){
return 1;
}
memcpy(*output, result.c_str(), rlen);
*output[rlen-1] = '\0';
return 0;
}
char *UnCipher(const char* data){
std::string tmp = OLO(std::string((char *)data));
char *out = b64_d(tmp.data());
return out;
}
};

int main(int argc, char **argv){
LCipher test(argv[2]);
char *out = nullptr;
test.Cipher(argv[1], &out);
char *out2 = test.UnCipher((const char *)out);
std::cout<<"Original : "<<argv[1]<<'\n';
std::cout<<"Cipher   : "<<out<<'\n';
std::cout<<"UnCipher : "<<out2<<'\n';
delete out;
delete out2;
return 0;
}
#92
Hacking / Re:Erica - Es hora de romper cosas 3:) ...
Diciembre 29, 2019, 02:39:55 AM
@No tienes permitido ver los links. Registrarse o Entrar a mi cuenta  Muy buena la herramienta.
#93
Underc0de / Re:Sorteo: Tarjeta de Regalo Google Play
Diciembre 29, 2019, 02:30:27 AM
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
@No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

No jo**s, es la segunda vez que me sorprendo con los códigos que dejan acá.

No lo habia probado, pero ahora que lo hago quedo perplejo.

~ DtxdF
Intente hacerlo parecer un arbol de navidad  ;D
Felicidades  :)
#94
Underc0de / Re:Sorteo: Tarjeta de Regalo Google Play
Diciembre 17, 2019, 09:24:02 PM
Código: c

                              #define\
                                _ 1
                             #include\
                             <stdio.h>
                         typedef int ____;
                        #define _______(__\ 
                        ){printf("%i ",__);}
                      #define  __(________){\
                    ____ ___  =_;____ ______=\
                  _;____ _____=_;for(______=_;\
                ______<________;){_______(______\
                       );___+=_____;_____=\
                      ______;______= ___;}}
                            ____ main
                            (){__(((_\
                            )*200) );}


Feliz navidad a todos  ;D